almost auto-fix on misc files

This commit is contained in:
Alex Barcelo 2016-10-23 22:09:17 +02:00
parent 3c35473265
commit 30e3aa55aa
10 changed files with 230 additions and 219 deletions

View File

@ -35,6 +35,7 @@ class CustomFieldMixin(object):
""" """
Mixin that provides a method to turn CustomFields into an actual field Mixin that provides a method to turn CustomFields into an actual field
""" """
def customfield_to_field(self, field, instanceargs): def customfield_to_field(self, field, instanceargs):
if field.data_type == 'varchar': if field.data_type == 'varchar':
fieldclass = forms.CharField fieldclass = forms.CharField
@ -76,6 +77,7 @@ class CustomFieldMixin(object):
class EditTicketForm(CustomFieldMixin, forms.ModelForm): class EditTicketForm(CustomFieldMixin, forms.ModelForm):
class Meta: class Meta:
model = Ticket model = Ticket
exclude = ('created', 'modified', 'status', 'on_hold', 'resolution', 'last_escalation', 'assigned_to') exclude = ('created', 'modified', 'status', 'on_hold', 'resolution', 'last_escalation', 'assigned_to')
@ -118,6 +120,7 @@ class EditTicketForm(CustomFieldMixin, forms.ModelForm):
class EditFollowUpForm(forms.ModelForm): class EditFollowUpForm(forms.ModelForm):
class Meta: class Meta:
model = FollowUp model = FollowUp
exclude = ('date', 'user',) exclude = ('date', 'user',)
@ -138,14 +141,14 @@ class TicketForm(CustomFieldMixin, forms.Form):
title = forms.CharField( title = forms.CharField(
max_length=100, max_length=100,
required=True, required=True,
widget=forms.TextInput(attrs={'size':'60'}), widget=forms.TextInput(attrs={'size': '60'}),
label=_('Summary of the problem'), label=_('Summary of the problem'),
) )
submitter_email = forms.EmailField( submitter_email = forms.EmailField(
required=False, required=False,
label=_('Submitter E-Mail Address'), label=_('Submitter E-Mail Address'),
widget=forms.TextInput(attrs={'size':'60'}), widget=forms.TextInput(attrs={'size': '60'}),
help_text=_('This e-mail address will receive copies of all public ' help_text=_('This e-mail address will receive copies of all public '
'updates to this ticket.'), 'updates to this ticket.'),
) )
@ -551,12 +554,14 @@ class UserSettingsForm(forms.Form):
class EmailIgnoreForm(forms.ModelForm): class EmailIgnoreForm(forms.ModelForm):
class Meta: class Meta:
model = IgnoreEmail model = IgnoreEmail
exclude = [] exclude = []
class TicketCCForm(forms.ModelForm): class TicketCCForm(forms.ModelForm):
class Meta: class Meta:
model = TicketCC model = TicketCC
exclude = ('ticket',) exclude = ('ticket',)
@ -571,6 +576,7 @@ class TicketCCForm(forms.ModelForm):
class TicketDependencyForm(forms.ModelForm): class TicketDependencyForm(forms.ModelForm):
class Meta: class Meta:
model = TicketDependency model = TicketDependency
exclude = ('ticket',) exclude = ('ticket',)

View File

@ -233,7 +233,7 @@ def safe_template_context(ticket):
context = { context = {
'queue': {}, 'queue': {},
'ticket': {}, 'ticket': {}
} }
queue = ticket.queue queue = ticket.queue

View File

@ -21,6 +21,7 @@ from helpdesk.models import EscalationExclusion, Queue
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self): def __init__(self):
BaseCommand.__init__(self) BaseCommand.__init__(self)

View File

@ -25,6 +25,7 @@ from helpdesk.models import Queue
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self): def __init__(self):
BaseCommand.__init__(self) BaseCommand.__init__(self)
@ -71,4 +72,3 @@ class Command(BaseCommand):
) )
except IntegrityError: except IntegrityError:
self.stdout.write(" .. permission already existed, skipping") self.stdout.write(" .. permission already existed, skipping")

View File

@ -28,6 +28,7 @@ from helpdesk.lib import send_templated_mail, safe_template_context
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self): def __init__(self):
BaseCommand.__init__(self) BaseCommand.__init__(self)
@ -88,16 +89,16 @@ def escalate_tickets(queues, verbose):
print("Processing: %s" % q) print("Processing: %s" % q)
for t in q.ticket_set.filter( for t in q.ticket_set.filter(
Q(status=Ticket.OPEN_STATUS) Q(status=Ticket.OPEN_STATUS) |
| Q(status=Ticket.REOPENED_STATUS) Q(status=Ticket.REOPENED_STATUS)
).exclude( ).exclude(
priority=1 priority=1
).filter( ).filter(
Q(on_hold__isnull=True) Q(on_hold__isnull=True) |
| Q(on_hold=False) Q(on_hold=False)
).filter( ).filter(
Q(last_escalation__lte=req_last_escl_date) Q(last_escalation__lte=req_last_escl_date) |
| Q(last_escalation__isnull=True, created__lte=req_last_escl_date) Q(last_escalation__isnull=True, created__lte=req_last_escl_date)
): ):
t.last_escalation = timezone.now() t.last_escalation = timezone.now()
@ -136,7 +137,7 @@ def escalate_tickets(queues, verbose):
if verbose: if verbose:
print(" - Esclating %s from %s>%s" % ( print(" - Esclating %s from %s>%s" % (
t.ticket, t.ticket,
t.priority+1, t.priority + 1,
t.priority t.priority
) )
) )

View File

@ -48,7 +48,9 @@ STRIPPED_SUBJECT_STRINGS = [
"Automatic reply: ", "Automatic reply: ",
] ]
class Command(BaseCommand): class Command(BaseCommand):
def __init__(self): def __init__(self):
BaseCommand.__init__(self) BaseCommand.__init__(self)
@ -74,7 +76,7 @@ def process_email(quiet=False):
allow_email_submission=True): allow_email_submission=True):
if not q.email_box_last_check: if not q.email_box_last_check:
q.email_box_last_check = timezone.now()-timedelta(minutes=30) q.email_box_last_check = timezone.now() - timedelta(minutes=30)
if not q.email_box_interval: if not q.email_box_interval:
q.email_box_interval = 0 q.email_box_interval = 0
@ -221,7 +223,7 @@ def ticket_from_message(message, queue, quiet):
return False return False
return True return True
matchobj = re.match(r".*\["+queue.slug+"-(?P<id>\d+)\]", subject) matchobj = re.match(r".*\[" + queue.slug + "-(?P<id>\d+)\]", subject)
if matchobj: if matchobj:
# This is a reply or forward. # This is a reply or forward.
ticket = matchobj.group('id') ticket = matchobj.group('id')
@ -400,4 +402,3 @@ def ticket_from_message(message, queue, quiet):
if __name__ == '__main__': if __name__ == '__main__':
process_email() process_email()

View File

@ -180,7 +180,6 @@ class Queue(models.Model):
help_text=_('Name used in the django.contrib.auth permission system'), help_text=_('Name used in the django.contrib.auth permission system'),
) )
email_box_interval = models.IntegerField( email_box_interval = models.IntegerField(
_('E-Mail Check Interval'), _('E-Mail Check Interval'),
help_text=_('How often do you wish to check this mailbox? (in Minutes)'), help_text=_('How often do you wish to check this mailbox? (in Minutes)'),
@ -479,7 +478,8 @@ class Ticket(models.Model):
Displays the ticket status, with an "On Hold" message if needed. Displays the ticket status, with an "On Hold" message if needed.
""" """
held_msg = '' held_msg = ''
if self.on_hold: held_msg = _(' - On Hold') if self.on_hold:
held_msg = _(' - On Hold')
dep_msg = '' dep_msg = ''
if not self.can_be_resolved: if not self.can_be_resolved:
dep_msg = _(' - Open dependencies') dep_msg = _(' - Open dependencies')
@ -569,6 +569,7 @@ class Ticket(models.Model):
class FollowUpManager(models.Manager): class FollowUpManager(models.Manager):
def private_followups(self): def private_followups(self):
return self.filter(public=False) return self.filter(public=False)
@ -597,7 +598,7 @@ class FollowUp(models.Model):
date = models.DateTimeField( date = models.DateTimeField(
_('Date'), _('Date'),
default = timezone.now default=timezone.now
) )
title = models.CharField( title = models.CharField(
@ -639,7 +640,7 @@ class FollowUp(models.Model):
objects = FollowUpManager() objects = FollowUpManager()
class Meta: class Meta:
ordering = ['date'] ordering = ('date',)
verbose_name = _('Follow-up') verbose_name = _('Follow-up')
verbose_name_plural = _('Follow-ups') verbose_name_plural = _('Follow-ups')
@ -711,7 +712,7 @@ def attachment_path(instance, filename):
import os import os
from django.conf import settings from django.conf import settings
os.umask(0) os.umask(0)
path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id ) path = 'helpdesk/attachments/%s/%s' % (instance.followup.ticket.ticket_for_url, instance.followup.id)
att_path = os.path.join(settings.MEDIA_ROOT, path) att_path = os.path.join(settings.MEDIA_ROOT, path)
if settings.DEFAULT_FILE_STORAGE == "django.core.files.storage.FileSystemStorage": if settings.DEFAULT_FILE_STORAGE == "django.core.files.storage.FileSystemStorage":
if not os.path.exists(att_path): if not os.path.exists(att_path):
@ -765,7 +766,7 @@ class Attachment(models.Model):
return '%s' % self.filename return '%s' % self.filename
class Meta: class Meta:
ordering = ['filename',] ordering = ('filename',)
verbose_name = _('Attachment') verbose_name = _('Attachment')
verbose_name_plural = _('Attachments') verbose_name_plural = _('Attachments')
@ -783,7 +784,7 @@ class PreSetReply(models.Model):
queue, and the body text is fetched via AJAX. queue, and the body text is fetched via AJAX.
""" """
class Meta: class Meta:
ordering = ['name', ] ordering = ('name',)
verbose_name = _('Pre-set reply') verbose_name = _('Pre-set reply')
verbose_name_plural = _('Pre-set replies') verbose_name_plural = _('Pre-set replies')
@ -904,7 +905,7 @@ class EmailTemplate(models.Model):
return '%s' % self.template_name return '%s' % self.template_name
class Meta: class Meta:
ordering = ['template_name', 'locale'] ordering = ('template_name', 'locale')
verbose_name = _('e-mail template') verbose_name = _('e-mail template')
verbose_name_plural = _('e-mail templates') verbose_name_plural = _('e-mail templates')
@ -933,7 +934,7 @@ class KBCategory(models.Model):
return '%s' % self.title return '%s' % self.title
class Meta: class Meta:
ordering = ['title',] ordering = ('title',)
verbose_name = _('Knowledge base category') verbose_name = _('Knowledge base category')
verbose_name_plural = _('Knowledge base categories') verbose_name_plural = _('Knowledge base categories')
@ -1000,7 +1001,7 @@ class KBItem(models.Model):
return '%s' % self.title return '%s' % self.title
class Meta: class Meta:
ordering = ['title',] ordering = ('title',)
verbose_name = _('Knowledge base item') verbose_name = _('Knowledge base item')
verbose_name_plural = _('Knowledge base items') verbose_name_plural = _('Knowledge base items')
@ -1263,6 +1264,7 @@ class TicketCC(models.Model):
class CustomFieldManager(models.Manager): class CustomFieldManager(models.Manager):
def get_queryset(self): def get_queryset(self):
return super(CustomFieldManager, self).get_queryset().order_by('ordering') return super(CustomFieldManager, self).get_queryset().order_by('ordering')