From 97887c4e9c0c3f11fd9f8411e848441263259912 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Wed, 19 Jun 2019 15:58:59 -0400 Subject: [PATCH 1/7] Allow disabling the random primary key test mixin Signed-off-by: Roberto Rosario --- HISTORY.rst | 5 ++ docs/releases/3.2.3.rst | 103 ++++++++++++++++++++++++++++++ docs/releases/index.rst | 1 + mayan/apps/common/tests/mixins.py | 69 ++++++++++---------- 4 files changed, 145 insertions(+), 33 deletions(-) create mode 100644 docs/releases/3.2.3.rst diff --git a/HISTORY.rst b/HISTORY.rst index afdc9794b6..c60dcfa746 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -1,3 +1,8 @@ +3.2.3 (2019-06-XX) +================== +* Add support for disabling the random primary key + test mixin. + 3.2.2 (2019-06-19) ================== * Fix document type change view. Closes GitLab issue #614 diff --git a/docs/releases/3.2.3.rst b/docs/releases/3.2.3.rst new file mode 100644 index 0000000000..60dc84d965 --- /dev/null +++ b/docs/releases/3.2.3.rst @@ -0,0 +1,103 @@ +Version 3.2.3 +============= + +Released: June XX, 2019 + + +Changes +------- + +- Add support for disabling the random primary key + test mixin. + + +Removals +-------- + +- None + + +Upgrading from a previous version +--------------------------------- + +If installed via Python's PIP +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Remove deprecated requirements:: + + $ curl https://gitlab.com/mayan-edms/mayan-edms/raw/master/removals.txt | pip uninstall -r /dev/stdin + +Type in the console:: + + $ pip install mayan-edms==3.2.1 + +the requirements will also be updated automatically. + + +Using Git +^^^^^^^^^ + +If you installed Mayan EDMS by cloning the Git repository issue the commands:: + + $ git reset --hard HEAD + $ git pull + +otherwise download the compressed archived and uncompress it overriding the +existing installation. + +Remove deprecated requirements:: + + $ pip uninstall -y -r removals.txt + +Next upgrade/add the new requirements:: + + $ pip install --upgrade -r requirements.txt + + +Common steps +^^^^^^^^^^^^ + +Perform these steps after updating the code from either step above. + +Make a backup of your supervisord file:: + + sudo cp /etc/supervisor/conf.d/mayan.conf /etc/supervisor/conf.d/mayan.conf.bck + +Update the supervisord configuration file. Replace the environment +variables values show here with your respective settings. This step will refresh +the supervisord configuration file with the new queues and the latest +recommended layout:: + + MAYAN_DATABASE_ENGINE=django.db.backends.postgresql MAYAN_DATABASE_NAME=mayan \ + MAYAN_DATABASE_PASSWORD=mayanuserpass MAYAN_DATABASE_USER=mayan \ + MAYAN_DATABASE_HOST=127.0.0.1 MAYAN_MEDIA_ROOT=/opt/mayan-edms/media \ + /opt/mayan-edms/bin/mayan-edms.py platformtemplate supervisord > /etc/supervisor/conf.d/mayan.conf + +Edit the supervisord configuration file and update any setting the template +generator missed:: + + vi /etc/supervisor/conf.d/mayan.conf + +Migrate existing database schema with:: + + $ mayan-edms.py performupgrade + +Add new static media:: + + $ mayan-edms.py preparestatic --noinput + +The upgrade procedure is now complete. + + +Backward incompatible changes +----------------------------- + +- None + + +Bugs fixed or issues closed +--------------------------- + +- :gitlab-issue:`615` + +.. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/docs/releases/index.rst b/docs/releases/index.rst index 9bd92aea1f..ec60a82fa4 100644 --- a/docs/releases/index.rst +++ b/docs/releases/index.rst @@ -20,6 +20,7 @@ versions of the documentation contain the release notes for any later releases. .. toctree:: :maxdepth: 1 + 3.2.3 3.2.2 3.2.1 3.2 diff --git a/mayan/apps/common/tests/mixins.py b/mayan/apps/common/tests/mixins.py index ce1f198bcf..1060f9c4ea 100644 --- a/mayan/apps/common/tests/mixins.py +++ b/mayan/apps/common/tests/mixins.py @@ -144,6 +144,7 @@ class RandomPrimaryKeyModelMonkeyPatchMixin(object): random_primary_key_random_floor = 100 random_primary_key_random_ceiling = 10000 random_primary_key_maximum_attempts = 100 + random_primary_key_enable = True @staticmethod def get_unique_primary_key(model): @@ -170,47 +171,49 @@ class RandomPrimaryKeyModelMonkeyPatchMixin(object): return primary_key def setUp(self): - self.method_save_original = models.Model.save + if self.random_primary_key_enable: + self.method_save_original = models.Model.save - def method_save_new(instance, *args, **kwargs): - if instance.pk: - return self.method_save_original(instance, *args, **kwargs) - else: - # Set meta.auto_created to True to have the original save_base - # not send the pre_save signal which would normally send - # the instance without a primary key. Since we assign a random - # primary key any pre_save signal handler that relies on an - # empty primary key will fail. - # The meta.auto_created and manual pre_save sending emulates - # the original behavior. Since meta.auto_created also disables - # the post_save signal we must also send it ourselves. - # This hack work with Django 1.11 .save_base() but can break - # in future versions if that method is updated. - pre_save.send( - sender=instance.__class__, instance=instance, raw=False, - update_fields=None, - ) - instance._meta.auto_created = True - instance.pk = RandomPrimaryKeyModelMonkeyPatchMixin.get_unique_primary_key( - model=instance._meta.model - ) - instance.id = instance.pk + def method_save_new(instance, *args, **kwargs): + if instance.pk: + return self.method_save_original(instance, *args, **kwargs) + else: + # Set meta.auto_created to True to have the original save_base + # not send the pre_save signal which would normally send + # the instance without a primary key. Since we assign a random + # primary key any pre_save signal handler that relies on an + # empty primary key will fail. + # The meta.auto_created and manual pre_save sending emulates + # the original behavior. Since meta.auto_created also disables + # the post_save signal we must also send it ourselves. + # This hack work with Django 1.11 .save_base() but can break + # in future versions if that method is updated. + pre_save.send( + sender=instance.__class__, instance=instance, raw=False, + update_fields=None, + ) + instance._meta.auto_created = True + instance.pk = RandomPrimaryKeyModelMonkeyPatchMixin.get_unique_primary_key( + model=instance._meta.model + ) + instance.id = instance.pk - result = instance.save_base(force_insert=True) - instance._meta.auto_created = False + result = instance.save_base(force_insert=True) + instance._meta.auto_created = False - post_save.send( - sender=instance.__class__, instance=instance, created=True, - update_fields=None, raw=False - ) + post_save.send( + sender=instance.__class__, instance=instance, created=True, + update_fields=None, raw=False + ) - return result + return result - setattr(models.Model, 'save', method_save_new) + setattr(models.Model, 'save', method_save_new) super(RandomPrimaryKeyModelMonkeyPatchMixin, self).setUp() def tearDown(self): - models.Model.save = self.method_save_original + if self.random_primary_key_enable: + models.Model.save = self.method_save_original super(RandomPrimaryKeyModelMonkeyPatchMixin, self).tearDown() From e09bd48d655ac87aae112d6606d982ce7682e924 Mon Sep 17 00:00:00 2001 From: Jesaja Everling Date: Thu, 20 Jun 2019 03:51:31 +0000 Subject: [PATCH 2/7] Fix kwargs for poplib.POP3_SSL and poplib.POP3 --- mayan/apps/sources/models/email_sources.py | 4 ++-- mayan/apps/sources/tests/test_models.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mayan/apps/sources/models/email_sources.py b/mayan/apps/sources/models/email_sources.py index 7b9f8b67d5..a681c7f721 100644 --- a/mayan/apps/sources/models/email_sources.py +++ b/mayan/apps/sources/models/email_sources.py @@ -277,10 +277,10 @@ class POP3Email(EmailBaseModel): logger.debug('ssl: %s', self.ssl) if self.ssl: - mailbox = poplib.POP3_SSL(host=self.host, post=self.port) + mailbox = poplib.POP3_SSL(host=self.host, port=self.port) else: mailbox = poplib.POP3( - host=self.host, post=self.port, timeout=self.timeout + host=self.host, port=self.port, timeout=self.timeout ) mailbox.getwelcome() diff --git a/mayan/apps/sources/tests/test_models.py b/mayan/apps/sources/tests/test_models.py index dfea4f640b..16a6282118 100644 --- a/mayan/apps/sources/tests/test_models.py +++ b/mayan/apps/sources/tests/test_models.py @@ -217,7 +217,7 @@ class POP3SourceTestCase(GenericDocumentTestCase): def user(self, username): return - @mock.patch('poplib.POP3_SSL') + @mock.patch('poplib.POP3_SSL', autospec=True) def test_download_document(self, mock_poplib): mock_poplib.return_value = POP3SourceTestCase.MockMailbox() self.source = POP3Email.objects.create( From 6f4802ac6a7b25ef423b1032ab976b95ca080b79 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 20 Jun 2019 23:14:33 -0400 Subject: [PATCH 3/7] Fix mailing profile log columns mappings GitLab issue #626. Thanks to Jesaja Everling (@jeverling) for the report. Signed-off-by: Roberto Rosario --- HISTORY.rst | 5 ++++- docs/releases/3.2.3.rst | 7 +++++-- mayan/apps/mailer/apps.py | 8 ++++++++ mayan/apps/mailer/views.py | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index c60dcfa746..71ae0306d5 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -2,7 +2,10 @@ ================== * Add support for disabling the random primary key test mixin. - +* Fix mailing profile log columns mappings. + GitLab issue #626. Thanks to Jesaja Everling (@jeverling) + for the report. + 3.2.2 (2019-06-19) ================== * Fix document type change view. Closes GitLab issue #614 diff --git a/docs/releases/3.2.3.rst b/docs/releases/3.2.3.rst index 60dc84d965..afa995fedc 100644 --- a/docs/releases/3.2.3.rst +++ b/docs/releases/3.2.3.rst @@ -9,7 +9,10 @@ Changes - Add support for disabling the random primary key test mixin. - +- Fix mailing profile log columns mappings. + GitLab issue #626. Thanks to Jesaja Everling (@jeverling) + for the report. + Removals -------- @@ -98,6 +101,6 @@ Backward incompatible changes Bugs fixed or issues closed --------------------------- -- :gitlab-issue:`615` +- :gitlab-issue:`626` Mailing profile error log is empty, despite errors .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/mailer/apps.py b/mayan/apps/mailer/apps.py index 61d5860136..6a6c89160b 100644 --- a/mayan/apps/mailer/apps.py +++ b/mayan/apps/mailer/apps.py @@ -51,6 +51,7 @@ class MailerApp(MayanAppConfig): LogEntry = self.get_model(model_name='LogEntry') UserMailer = self.get_model(model_name='UserMailer') + UserMailerLogEntry = self.get_model(model_name='UserMailerLogEntry') MailerBackend.initialize() @@ -79,6 +80,13 @@ class MailerApp(MayanAppConfig): SourceColumn( source=UserMailer, attribute='backend_label' ) + SourceColumn( + attribute='datetime', label=_('Date and time'), + source=UserMailerLogEntry + ) + SourceColumn( + attribute='message', label=_('Message'), source=UserMailerLogEntry + ) ModelPermission.register( model=Document, permissions=( diff --git a/mayan/apps/mailer/views.py b/mayan/apps/mailer/views.py index ca8193d479..b2477c422e 100644 --- a/mayan/apps/mailer/views.py +++ b/mayan/apps/mailer/views.py @@ -208,7 +208,7 @@ class UserMailerLogEntryListView(SingleObjectListView): return { 'hide_object': True, 'object': self.get_user_mailer(), - 'title': _('%s error log') % self.get_user_mailer(), + 'title': _('Error log for: %s') % self.get_user_mailer(), } def get_source_queryset(self): From 440822896aa4a156ffb9039aa2b74d990e448435 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 20 Jun 2019 23:42:16 -0400 Subject: [PATCH 4/7] Fix the Django SMTP backend username field name Increase the Django STMP username. GitLab issue #625. Thanks to Jesaja Everling (@jeverling) for the report and the research. Signed-off-by: Roberto Rosario --- HISTORY.rst | 6 ++++++ docs/releases/3.2.3.rst | 7 +++++++ mayan/apps/mailer/forms.py | 2 +- mayan/apps/mailer/mailers.py | 8 ++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 71ae0306d5..024948f6dc 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -5,6 +5,12 @@ * Fix mailing profile log columns mappings. GitLab issue #626. Thanks to Jesaja Everling (@jeverling) for the report. +* Fix the Django SMTP backend username field name. + GitLab issue #625. Thanks to Jesaja Everling (@jeverling) + for the report and the research. +* Increase the Django STMP username. + GitLab issue #625. Thanks to Jesaja Everling (@jeverling) + for the report and the research. 3.2.2 (2019-06-19) ================== diff --git a/docs/releases/3.2.3.rst b/docs/releases/3.2.3.rst index afa995fedc..4dca435e4f 100644 --- a/docs/releases/3.2.3.rst +++ b/docs/releases/3.2.3.rst @@ -12,6 +12,12 @@ Changes - Fix mailing profile log columns mappings. GitLab issue #626. Thanks to Jesaja Everling (@jeverling) for the report. +- Fix the Django SMTP backend username field name. + GitLab issue #625. Thanks to Jesaja Everling (@jeverling) + for the report and the research. +- Increase the Django STMP username. + GitLab issue #625. Thanks to Jesaja Everling (@jeverling) + for the report and the research. Removals @@ -101,6 +107,7 @@ Backward incompatible changes Bugs fixed or issues closed --------------------------- +- :gitlab-issue:`625` mayan.apps.mailer.mailers.DjangoSMTP uses "user", but django.core.mail.backends.smtp.EmailBackend expects "username" - :gitlab-issue:`626` Mailing profile error log is empty, despite errors .. _PyPI: https://pypi.python.org/pypi/mayan-edms/ diff --git a/mayan/apps/mailer/forms.py b/mayan/apps/mailer/forms.py index e2f51b339c..4373b2a3ab 100644 --- a/mayan/apps/mailer/forms.py +++ b/mayan/apps/mailer/forms.py @@ -96,7 +96,7 @@ class UserMailerDynamicForm(DynamicModelForm): if self.instance.backend_data: backend_data = json.loads(self.instance.backend_data) for key in self.instance.get_backend().fields: - self.fields[key].initial = backend_data[key] + self.fields[key].initial = backend_data.get(key) return result diff --git a/mayan/apps/mailer/mailers.py b/mayan/apps/mailer/mailers.py index 9e4660f2ba..4407c7e9b0 100644 --- a/mayan/apps/mailer/mailers.py +++ b/mayan/apps/mailer/mailers.py @@ -12,11 +12,11 @@ class DjangoSMTP(MailerBackend): Backend that wraps Django's SMTP backend """ class_fields = ( - 'host', 'port', 'use_tls', 'use_ssl', 'user', 'password' + 'host', 'port', 'use_tls', 'use_ssl', 'username', 'password' ) class_path = 'django.core.mail.backends.smtp.EmailBackend' field_order = ( - 'host', 'port', 'use_tls', 'use_ssl', 'user', 'password', 'from' + 'host', 'port', 'use_tls', 'use_ssl', 'username', 'password', 'from' ) fields = { 'from': { @@ -60,14 +60,14 @@ class DjangoSMTP(MailerBackend): 'that "Use TLS" and "Use SSL" are mutually exclusive, ' 'so only set one of those settings to True.' ), 'required': False - }, 'user': { + }, 'username': { 'label': _('Username'), 'class': 'django.forms.CharField', 'default': '', 'help_text': _( 'Username to use for the SMTP server. If empty, ' 'authentication won\'t attempted.' ), 'kwargs': { - 'max_length': 48 + 'max_length': 254 }, 'required': False }, 'password': { 'label': _('Password'), From a77708ebe66152580ea2165549794bb707684a79 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Thu, 20 Jun 2019 23:52:00 -0400 Subject: [PATCH 5/7] Update release notes Signed-off-by: Roberto Rosario --- docs/releases/3.2.3.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/releases/3.2.3.rst b/docs/releases/3.2.3.rst index 4dca435e4f..57e9532b9f 100644 --- a/docs/releases/3.2.3.rst +++ b/docs/releases/3.2.3.rst @@ -107,6 +107,7 @@ Backward incompatible changes Bugs fixed or issues closed --------------------------- +- :gitlab-issue:`619` poplib.POP3_SSL and poplib.POP3 initialized with wrong kwarg - :gitlab-issue:`625` mayan.apps.mailer.mailers.DjangoSMTP uses "user", but django.core.mail.backends.smtp.EmailBackend expects "username" - :gitlab-issue:`626` Mailing profile error log is empty, despite errors From 2d875ff0445f1a426bc6be7e58910636db8aa73f Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 21 Jun 2019 00:01:37 -0400 Subject: [PATCH 6/7] Bump version to 3.2.3 Signed-off-by: Roberto Rosario --- docker/rootfs/version | 2 +- mayan/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docker/rootfs/version b/docker/rootfs/version index be94e6f53d..b347b11eac 100755 --- a/docker/rootfs/version +++ b/docker/rootfs/version @@ -1 +1 @@ -3.2.2 +3.2.3 diff --git a/mayan/__init__.py b/mayan/__init__.py index ee860aa2c4..ea60e264b2 100644 --- a/mayan/__init__.py +++ b/mayan/__init__.py @@ -1,9 +1,9 @@ from __future__ import unicode_literals __title__ = 'Mayan EDMS' -__version__ = '3.2.2' -__build__ = 0x030202 -__build_string__ = 'v3.2.2_Wed Jun 19 00:39:13 2019 -0400' +__version__ = '3.2.3' +__build__ = 0x030203 +__build_string__ = 'v3.2.2-9-ga77708ebe6_Thu Jun 20 23:52:00 2019 -0400' __django_version__ = '1.11' __author__ = 'Roberto Rosario' __author_email__ = 'roberto.rosario@mayan-edms.com' From 0f5f8c0dd176f673025cc13cb38f17b7371ac9b3 Mon Sep 17 00:00:00 2001 From: Roberto Rosario Date: Fri, 21 Jun 2019 00:03:53 -0400 Subject: [PATCH 7/7] Update build number Signed-off-by: Roberto Rosario --- mayan/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mayan/__init__.py b/mayan/__init__.py index ea60e264b2..d64fa74a55 100644 --- a/mayan/__init__.py +++ b/mayan/__init__.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals __title__ = 'Mayan EDMS' __version__ = '3.2.3' __build__ = 0x030203 -__build_string__ = 'v3.2.2-9-ga77708ebe6_Thu Jun 20 23:52:00 2019 -0400' +__build_string__ = 'v3.2.3_Fri Jun 21 00:01:37 2019 -0400' __django_version__ = '1.11' __author__ = 'Roberto Rosario' __author_email__ = 'roberto.rosario@mayan-edms.com'