diff --git a/helpdesk/email.py b/helpdesk/email.py index 96f3ec13..40652dc9 100644 --- a/helpdesk/email.py +++ b/helpdesk/email.py @@ -11,6 +11,17 @@ scripts/get_email.py - Designed to be run from cron, this script checks the helpdesk, creating tickets from the new messages (or adding to existing tickets if needed) """ +from django.core.files.base import ContentFile +from django.core.files.uploadedfile import SimpleUploadedFile +from django.core.management.base import BaseCommand +from django.db.models import Q +from django.utils.translation import ugettext as _ +from django.utils import encoding, timezone +from django.contrib.auth.models import User + +from helpdesk import settings +from helpdesk.lib import safe_template_context, process_attachments +from helpdesk.models import Queue, Ticket, TicketCC, FollowUp, IgnoreEmail from datetime import timedelta import base64 @@ -31,18 +42,6 @@ from bs4 import BeautifulSoup from email_reply_parser import EmailReplyParser -from django.core.files.base import ContentFile -from django.core.files.uploadedfile import SimpleUploadedFile -from django.core.management.base import BaseCommand -from django.db.models import Q -from django.utils.translation import ugettext as _ -from django.utils import encoding, timezone - -from helpdesk import settings -from helpdesk.lib import safe_template_context, process_attachments -from helpdesk.models import Queue, Ticket, TicketCC, FollowUp, IgnoreEmail -from django.contrib.auth.models import User - import logging diff --git a/helpdesk/forms.py b/helpdesk/forms.py index 8cea3455..b2af26d5 100644 --- a/helpdesk/forms.py +++ b/helpdesk/forms.py @@ -9,7 +9,6 @@ forms.py - Definitions of newforms-based forms for creating and maintaining from django.core.exceptions import ObjectDoesNotExist -from django.utils.six import StringIO from django import forms from django.forms import widgets from django.conf import settings diff --git a/helpdesk/management/commands/create_escalation_exclusions.py b/helpdesk/management/commands/create_escalation_exclusions.py index fcda257d..8801e0f0 100644 --- a/helpdesk/management/commands/create_escalation_exclusions.py +++ b/helpdesk/management/commands/create_escalation_exclusions.py @@ -8,17 +8,15 @@ scripts/create_escalation_exclusion.py - Easy way to routinely add particular days to the list of days on which no escalation should take place. """ -from __future__ import print_function +from django.core.management.base import BaseCommand, CommandError + +from helpdesk.models import EscalationExclusion, Queue from datetime import timedelta, date import getopt from optparse import make_option import sys -from django.core.management.base import BaseCommand, CommandError - -from helpdesk.models import EscalationExclusion, Queue - class Command(BaseCommand): diff --git a/helpdesk/management/commands/escalate_tickets.py b/helpdesk/management/commands/escalate_tickets.py index 88d26e31..28592dde 100644 --- a/helpdesk/management/commands/escalate_tickets.py +++ b/helpdesk/management/commands/escalate_tickets.py @@ -7,7 +7,6 @@ django-helpdesk - A Django powered ticket tracker for small enterprise. scripts/escalate_tickets.py - Easy way to escalate tickets based on their age, designed to be run from Cron or similar. """ -from __future__ import print_function from datetime import timedelta, date import getopt @@ -17,11 +16,7 @@ import sys from django.core.management.base import BaseCommand, CommandError from django.db.models import Q from django.utils.translation import ugettext as _ - -try: - from django.utils import timezone -except ImportError: - from datetime import datetime as timezone +from django.utils import timezone from helpdesk.models import Queue, Ticket, FollowUp, EscalationExclusion, TicketChange from helpdesk.lib import safe_template_context diff --git a/helpdesk/migrations/0001_initial.py b/helpdesk/migrations/0001_initial.py index 3bd49746..8ae60e4a 100644 --- a/helpdesk/migrations/0001_initial.py +++ b/helpdesk/migrations/0001_initial.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations import django.utils.timezone from django.conf import settings + import helpdesk.models diff --git a/helpdesk/migrations/0002_populate_usersettings.py b/helpdesk/migrations/0002_populate_usersettings.py index ba2979be..9c60205f 100644 --- a/helpdesk/migrations/0002_populate_usersettings.py +++ b/helpdesk/migrations/0002_populate_usersettings.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.contrib.auth import get_user_model from django.db import models, migrations diff --git a/helpdesk/migrations/0003_initial_data_import.py b/helpdesk/migrations/0003_initial_data_import.py index cc478377..c13bb47c 100644 --- a/helpdesk/migrations/0003_initial_data_import.py +++ b/helpdesk/migrations/0003_initial_data_import.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - import os from sys import path diff --git a/helpdesk/migrations/0004_add_per_queue_staff_membership.py b/helpdesk/migrations/0004_add_per_queue_staff_membership.py index 1b96b3bc..d3a444f4 100644 --- a/helpdesk/migrations/0004_add_per_queue_staff_membership.py +++ b/helpdesk/migrations/0004_add_per_queue_staff_membership.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations from django.conf import settings diff --git a/helpdesk/migrations/0005_queues_no_null.py b/helpdesk/migrations/0005_queues_no_null.py index 8a678635..e7e2ba76 100644 --- a/helpdesk/migrations/0005_queues_no_null.py +++ b/helpdesk/migrations/0005_queues_no_null.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0006_email_maxlength.py b/helpdesk/migrations/0006_email_maxlength.py index 7c50b32a..e1e37927 100644 --- a/helpdesk/migrations/0006_email_maxlength.py +++ b/helpdesk/migrations/0006_email_maxlength.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0007_max_length_by_integer.py b/helpdesk/migrations/0007_max_length_by_integer.py index 98b404a8..5b8deba3 100644 --- a/helpdesk/migrations/0007_max_length_by_integer.py +++ b/helpdesk/migrations/0007_max_length_by_integer.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0008_extra_for_permissions.py b/helpdesk/migrations/0008_extra_for_permissions.py index ac6d1433..d9a75aa9 100644 --- a/helpdesk/migrations/0008_extra_for_permissions.py +++ b/helpdesk/migrations/0008_extra_for_permissions.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0009_migrate_queuemembership.py b/helpdesk/migrations/0009_migrate_queuemembership.py index 10d27cd0..09e2a60f 100644 --- a/helpdesk/migrations/0009_migrate_queuemembership.py +++ b/helpdesk/migrations/0009_migrate_queuemembership.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.core.exceptions import ObjectDoesNotExist from django.db import migrations from django.db.utils import IntegrityError diff --git a/helpdesk/migrations/0010_remove_queuemembership.py b/helpdesk/migrations/0010_remove_queuemembership.py index 3b097365..b0df7ee4 100644 --- a/helpdesk/migrations/0010_remove_queuemembership.py +++ b/helpdesk/migrations/0010_remove_queuemembership.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0011_admin_related_improvements.py b/helpdesk/migrations/0011_admin_related_improvements.py index a36ff1fb..1ac25317 100644 --- a/helpdesk/migrations/0011_admin_related_improvements.py +++ b/helpdesk/migrations/0011_admin_related_improvements.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import models, migrations diff --git a/helpdesk/migrations/0012_queue_default_owner.py b/helpdesk/migrations/0012_queue_default_owner.py index 7a731e00..aa8af6f4 100644 --- a/helpdesk/migrations/0012_queue_default_owner.py +++ b/helpdesk/migrations/0012_queue_default_owner.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.9.2 on 2016-02-15 21:37 -from __future__ import unicode_literals - from django.conf import settings from django.db import migrations, models import django.db.models.deletion diff --git a/helpdesk/migrations/0013_email_box_local_dir_and_logging.py b/helpdesk/migrations/0013_email_box_local_dir_and_logging.py index 71ba784e..6fc936ca 100644 --- a/helpdesk/migrations/0013_email_box_local_dir_and_logging.py +++ b/helpdesk/migrations/0013_email_box_local_dir_and_logging.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2016-09-14 23:47 -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/helpdesk/migrations/0014_usersettings_related_name.py b/helpdesk/migrations/0014_usersettings_related_name.py index ab58ee01..857e0293 100644 --- a/helpdesk/migrations/0014_usersettings_related_name.py +++ b/helpdesk/migrations/0014_usersettings_related_name.py @@ -1,6 +1,4 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals - from django.db import migrations, models from django.conf import settings diff --git a/helpdesk/migrations/0015_expand_permission_name_size.py b/helpdesk/migrations/0015_expand_permission_name_size.py index 5feecb38..b5aa3a1d 100644 --- a/helpdesk/migrations/0015_expand_permission_name_size.py +++ b/helpdesk/migrations/0015_expand_permission_name_size.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.5 on 2017-02-10 19:27 -from __future__ import unicode_literals - from django.db import migrations, models diff --git a/helpdesk/migrations/0016_alter_model_options.py b/helpdesk/migrations/0016_alter_model_options.py index a265317a..426b5864 100644 --- a/helpdesk/migrations/0016_alter_model_options.py +++ b/helpdesk/migrations/0016_alter_model_options.py @@ -1,7 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.10.2 on 2017-03-08 17:51 -from __future__ import unicode_literals - from django.db import migrations diff --git a/helpdesk/migrations/0017_default_owner_on_delete_null.py b/helpdesk/migrations/0017_default_owner_on_delete_null.py index 54591f64..ee8cad36 100644 --- a/helpdesk/migrations/0017_default_owner_on_delete_null.py +++ b/helpdesk/migrations/0017_default_owner_on_delete_null.py @@ -1,8 +1,5 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.2 on 2018-01-19 09:48 - -from __future__ import unicode_literals - from django.conf import settings from django.db import migrations, models import django.db.models.deletion diff --git a/helpdesk/migrations/0018_ticket_secret_key.py b/helpdesk/migrations/0018_ticket_secret_key.py index f3b2f4ee..bafd807c 100644 --- a/helpdesk/migrations/0018_ticket_secret_key.py +++ b/helpdesk/migrations/0018_ticket_secret_key.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.1 on 2018-09-07 21:22 - from django.db import migrations, models import helpdesk.models diff --git a/helpdesk/migrations/0019_ticket_secret_key.py b/helpdesk/migrations/0019_ticket_secret_key.py index be1dd385..ed3847da 100644 --- a/helpdesk/migrations/0019_ticket_secret_key.py +++ b/helpdesk/migrations/0019_ticket_secret_key.py @@ -1,5 +1,4 @@ # Generated by Django 2.0.1 on 2018-09-07 21:22 - from django.db import migrations, models import helpdesk.models diff --git a/helpdesk/migrations/0020_depickle_user_settings.py b/helpdesk/migrations/0020_depickle_user_settings.py index 556dcafe..d5a550a1 100644 --- a/helpdesk/migrations/0020_depickle_user_settings.py +++ b/helpdesk/migrations/0020_depickle_user_settings.py @@ -1,8 +1,8 @@ # Generated by Django 2.0.7 on 2018-10-19 14:11 - from django.db import migrations, models import helpdesk.models + def unpickle_settings(settings_pickled): # return a python dictionary representing the pickled data. try: @@ -11,13 +11,11 @@ def unpickle_settings(settings_pickled): import cPickle as pickle from helpdesk.lib import b64decode try: - if six.PY2: - return pickle.loads(b64decode(str(settings_pickled))) - else: - return pickle.loads(b64decode(settings_pickled.encode('utf-8'))) + return pickle.loads(b64decode(settings_pickled.encode('utf-8'))) except Exception: return {} + def move_old_values(apps, schema_editor): UserSettings = apps.get_model("helpdesk", "UserSettings") db_alias = schema_editor.connection.alias @@ -28,6 +26,7 @@ def move_old_values(apps, schema_editor): for setting, value in settings_dict.items(): user_settings.__set_attr__(setting, value) + class Migration(migrations.Migration): dependencies = [ diff --git a/helpdesk/migrations/0021_voting_tracker.py b/helpdesk/migrations/0021_voting_tracker.py index 26e49d63..691977a2 100644 --- a/helpdesk/migrations/0021_voting_tracker.py +++ b/helpdesk/migrations/0021_voting_tracker.py @@ -1,5 +1,4 @@ # Generated by Django 2.1.2 on 2018-10-17 17:37 - from django.conf import settings from django.db import migrations, models diff --git a/helpdesk/models.py b/helpdesk/models.py index 89f1a08b..a3080f8b 100644 --- a/helpdesk/models.py +++ b/helpdesk/models.py @@ -7,7 +7,6 @@ models.py - Model (and hence database) definitions. This is the core of the helpdesk structure. """ -from __future__ import unicode_literals from django.contrib.auth.models import Permission from django.contrib.auth import get_user_model from django.contrib.contenttypes.models import ContentType @@ -15,18 +14,15 @@ from django.core.exceptions import ObjectDoesNotExist from django.db import models from django.conf import settings from django.utils import timezone -from django.utils import six from django.utils.translation import ugettext_lazy as _, ugettext -from django.utils.encoding import python_2_unicode_compatible +from io import StringIO import re -import six import uuid from .templated_email import send_templated_mail -@python_2_unicode_compatible class Queue(models.Model): """ A queue is a collection of tickets into what would generally be business @@ -358,7 +354,6 @@ def mk_secret(): return str(uuid.uuid4()) -@python_2_unicode_compatible class Ticket(models.Model): """ To allow a ticket to be entered as quickly as possible, only the @@ -694,7 +689,6 @@ class FollowUpManager(models.Manager): return self.filter(public=True) -@python_2_unicode_compatible class FollowUp(models.Model): """ A FollowUp is a comment and/or change to a ticket. We keep a simple @@ -776,7 +770,6 @@ class FollowUp(models.Model): super(FollowUp, self).save(*args, **kwargs) -@python_2_unicode_compatible class TicketChange(models.Model): """ For each FollowUp, any changes to the parent ticket (eg Title, Priority, @@ -839,7 +832,6 @@ def attachment_path(instance, filename): return os.path.join(path, filename) -@python_2_unicode_compatible class Attachment(models.Model): """ Represents a file attached to a follow-up. This could come from an e-mail @@ -882,7 +874,6 @@ class Attachment(models.Model): verbose_name_plural = _('Attachments') -@python_2_unicode_compatible class PreSetReply(models.Model): """ We can allow the admin to define a number of pre-set replies, used to @@ -924,7 +915,6 @@ class PreSetReply(models.Model): return '%s' % self.name -@python_2_unicode_compatible class EscalationExclusion(models.Model): """ An 'EscalationExclusion' lets us define a date on which escalation should @@ -961,7 +951,6 @@ class EscalationExclusion(models.Model): verbose_name_plural = _('Escalation exclusions') -@python_2_unicode_compatible class EmailTemplate(models.Model): """ Since these are more likely to be changed than other templates, we store @@ -1021,7 +1010,6 @@ class EmailTemplate(models.Model): verbose_name_plural = _('e-mail templates') -@python_2_unicode_compatible class KBCategory(models.Model): """ Lets help users help themselves: the Knowledge Base is a categorised @@ -1054,7 +1042,6 @@ class KBCategory(models.Model): return reverse('helpdesk:kb_category', kwargs={'slug': self.slug}) -@python_2_unicode_compatible class KBItem(models.Model): """ An item within the knowledgebase. Very straightforward question/answer @@ -1123,7 +1110,6 @@ class KBItem(models.Model): return reverse('helpdesk:kb_item', args=(self.id,)) -@python_2_unicode_compatible class SavedSearch(models.Model): """ Allow a user to save a ticket search, eg their filtering and sorting @@ -1195,7 +1181,6 @@ def use_email_as_submitter_default(): return get_default_setting('use_email_as_submitter') -@python_2_unicode_compatible class UserSettings(models.Model): """ A bunch of user-specific settings that we want to be able to define, such @@ -1275,7 +1260,6 @@ def create_usersettings(sender, instance, created, **kwargs): models.signals.post_save.connect(create_usersettings, sender=settings.AUTH_USER_MODEL) -@python_2_unicode_compatible class IgnoreEmail(models.Model): """ This model lets us easily ignore e-mails from certain senders when @@ -1362,7 +1346,6 @@ class IgnoreEmail(models.Model): return False -@python_2_unicode_compatible class TicketCC(models.Model): """ Often, there are people who wish to follow a ticket who aren't the @@ -1433,7 +1416,6 @@ class CustomFieldManager(models.Manager): return super(CustomFieldManager, self).get_queryset().order_by('ordering') -@python_2_unicode_compatible class CustomField(models.Model): """ Definitions for custom fields that are glued onto each ticket. @@ -1517,7 +1499,6 @@ class CustomField(models.Model): ) def _choices_as_array(self): - from django.utils.six import StringIO valuebuffer = StringIO(self.list_values) choices = [[item.strip(), item.strip()] for item in valuebuffer.readlines()] valuebuffer.close() @@ -1547,7 +1528,6 @@ class CustomField(models.Model): verbose_name_plural = _('Custom fields') -@python_2_unicode_compatible class TicketCustomFieldValue(models.Model): ticket = models.ForeignKey( Ticket, @@ -1572,7 +1552,6 @@ class TicketCustomFieldValue(models.Model): verbose_name_plural = _('Ticket custom field values') -@python_2_unicode_compatible class TicketDependency(models.Model): """ The ticket identified by `ticket` cannot be resolved until the ticket in `depends_on` has been resolved. diff --git a/helpdesk/templatetags/load_helpdesk_settings.py b/helpdesk/templatetags/load_helpdesk_settings.py index b16838f9..de92a551 100644 --- a/helpdesk/templatetags/load_helpdesk_settings.py +++ b/helpdesk/templatetags/load_helpdesk_settings.py @@ -4,7 +4,6 @@ django-helpdesk - A Django powered ticket tracker for small enterprise. templatetags/load_helpdesk_settings.py - returns the settings as defined in django-helpdesk/helpdesk/settings.py """ -from __future__ import print_function from django.template import Library from helpdesk import settings as helpdesk_settings_config diff --git a/helpdesk/templatetags/saved_queries.py b/helpdesk/templatetags/saved_queries.py index 9dd53bf7..c3f667d3 100644 --- a/helpdesk/templatetags/saved_queries.py +++ b/helpdesk/templatetags/saved_queries.py @@ -5,9 +5,9 @@ templatetags/saved_queries.py - This template tag returns previously saved queries. Therefore you don't need to modify any views. """ -from __future__ import print_function from django.template import Library from django.db.models import Q + from helpdesk.models import SavedSearch diff --git a/helpdesk/templatetags/ticket_to_link.py b/helpdesk/templatetags/ticket_to_link.py index f62f590b..39683bfb 100644 --- a/helpdesk/templatetags/ticket_to_link.py +++ b/helpdesk/templatetags/ticket_to_link.py @@ -10,15 +10,14 @@ templatetags/ticket_to_link.py - Used in ticket comments to allow wiki-style to show the status of that ticket (eg a closed ticket would have a strikethrough). """ - -import re - from django import template from django.urls import reverse from django.utils.safestring import mark_safe from helpdesk.models import Ticket +import re + def num_to_link(text): if text == '': diff --git a/helpdesk/tests/helpers.py b/helpdesk/tests/helpers.py index ef2c73ee..4aad4914 100644 --- a/helpdesk/tests/helpers.py +++ b/helpdesk/tests/helpers.py @@ -22,11 +22,7 @@ def get_staff_user(username='helpdesk.staff', password='password'): def reload_urlconf(urlconf=None): - from django.utils import six - if six.PY2: - from imp import reload - else: - from importlib import reload + from importlib import reload if urlconf is None: from django.conf import settings diff --git a/helpdesk/tests/test_attachments.py b/helpdesk/tests/test_attachments.py index ebc6a8d9..5433e378 100644 --- a/helpdesk/tests/test_attachments.py +++ b/helpdesk/tests/test_attachments.py @@ -1,10 +1,4 @@ # vim: set fileencoding=utf-8 : -from __future__ import unicode_literals - -import os -import shutil -from tempfile import gettempdir - from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from django.test import override_settings, TestCase @@ -12,12 +6,12 @@ from django.utils.encoding import smart_text from helpdesk import lib, models -try: - # Python >= 3.3 - from unittest import mock -except ImportError: - # Python < 3.3 - import mock +import os +import shutil +from tempfile import gettempdir + +from unittest import mock + MEDIA_DIR = os.path.join(gettempdir(), 'helpdesk_test_media') diff --git a/helpdesk/tests/test_get_email.py b/helpdesk/tests/test_get_email.py index fb97708c..546da873 100644 --- a/helpdesk/tests/test_get_email.py +++ b/helpdesk/tests/test_get_email.py @@ -1,30 +1,21 @@ # -*- coding: utf-8 -*- - -from __future__ import unicode_literals - -from helpdesk.models import Queue, Ticket, TicketCC, FollowUp, Attachment from django.test import TestCase from django.core.management import call_command -from django.utils import six from django.shortcuts import get_object_or_404 from django.contrib.auth.models import User from django.contrib.auth.hashers import make_password + +from helpdesk.models import Queue, Ticket, TicketCC, FollowUp, Attachment + import itertools from shutil import rmtree import sys from tempfile import mkdtemp -try: # python 3 - from urllib.parse import urlparse -except ImportError: # python 2 - from urlparse import urlparse -try: - # Python >= 3.3 - from unittest import mock -except ImportError: - # Python < 3.3 - import mock +from urllib.parse import urlparse + +from unittest import mock # class A addresses can't have first octet of 0 unrouted_socks_server = "0.0.0.1" @@ -100,7 +91,7 @@ class GetEmailParametricTemplate(object): if self.method == 'local': with mock.patch('helpdesk.email.listdir') as mocked_listdir, \ mock.patch('helpdesk.email.isfile') as mocked_isfile, \ - mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=test_email)): + mock.patch('builtins.open', mock.mock_open(read_data=test_email)): mocked_isfile.return_value = True mocked_listdir.return_value = ['filename1', 'filename2'] @@ -173,7 +164,7 @@ class GetEmailParametricTemplate(object): if self.method == 'local': with mock.patch('helpdesk.email.listdir') as mocked_listdir, \ mock.patch('helpdesk.email.isfile') as mocked_isfile, \ - mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=test_email)): + mock.patch('builtins.open', mock.mock_open(read_data=test_email)): mocked_isfile.return_value = True mocked_listdir.return_value = ['filename1', 'filename2'] @@ -286,7 +277,7 @@ class GetEmailParametricTemplate(object): if self.method == 'local': with mock.patch('helpdesk.email.listdir') as mocked_listdir, \ mock.patch('helpdesk.email.isfile') as mocked_isfile, \ - mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=msg.as_string())): + mock.patch('builtins.open', mock.mock_open(read_data=msg.as_string())): mocked_isfile.return_value = True mocked_listdir.return_value = ['filename1', 'filename2'] @@ -533,7 +524,7 @@ a9eiiQ+3V1v+7wWHXCzq if self.method == 'local': with mock.patch('helpdesk.email.listdir') as mocked_listdir, \ mock.patch('helpdesk.email.isfile') as mocked_isfile, \ - mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=test_email)): + mock.patch('builtins.open', mock.mock_open(read_data=test_email)): mocked_isfile.return_value = True mocked_listdir.return_value = ['filename1'] @@ -703,7 +694,7 @@ class GetEmailCCHandling(TestCase): with mock.patch('helpdesk.email.listdir') as mocked_listdir, \ mock.patch('helpdesk.email.isfile') as mocked_isfile, \ - mock.patch('builtins.open' if six.PY3 else '__builtin__.open', mock.mock_open(read_data=test_email)): + mock.patch('builtins.open', mock.mock_open(read_data=test_email)): mocked_isfile.return_value = True mocked_listdir.return_value = ['filename1'] diff --git a/helpdesk/views/staff.py b/helpdesk/views/staff.py index 9dbb8d65..b4baed1f 100644 --- a/helpdesk/views/staff.py +++ b/helpdesk/views/staff.py @@ -6,10 +6,6 @@ django-helpdesk - A Django powered ticket tracker for small enterprise. views/staff.py - The bulk of the application - provides most business logic and renders all staff-facing views. """ -from __future__ import unicode_literals -from datetime import date, datetime, timedelta -import re - from django import VERSION as DJANGO_VERSION from django.conf import settings from django.contrib.auth import get_user_model @@ -27,14 +23,9 @@ from django.utils.html import escape from django import forms from django.utils import timezone from django.views.generic.edit import FormView, UpdateView - -from django.utils import six - # For datatables serverside from django.core.cache import cache -from rest_framework import viewsets, status -from rest_framework.response import Response -from rest_framework.decorators import api_view + from helpdesk.lib import query_tickets_by_args from helpdesk.serializers import TicketSerializer @@ -57,6 +48,14 @@ from helpdesk.models import ( from helpdesk import settings as helpdesk_settings from helpdesk.views.permissions import MustBeStaffMixin +from rest_framework import viewsets, status +from rest_framework.response import Response +from rest_framework.decorators import api_view + +from datetime import date, datetime, timedelta +import re + + User = get_user_model() if helpdesk_settings.HELPDESK_ALLOW_NON_STAFF_TICKET_UPDATE: diff --git a/setup.py b/setup.py index 918241ba..7ff6c0c2 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ from distutils.util import convert_path from fnmatch import fnmatchcase from setuptools import setup, find_packages -version = '0.3.0.dev1' +version = '0.3.0.dev2' # Provided as an attribute, so you can append to these instead # of replicating them: