mirror of
https://github.com/django-helpdesk/django-helpdesk.git
synced 2025-06-24 11:33:38 +02:00
Merge pull request #438 from alexbarcelo/autocodestyle
More Code Style --PEP8-centric
This commit is contained in:
commit
44fd60970b
@ -20,9 +20,13 @@ install:
|
|||||||
- pip install argparse
|
- pip install argparse
|
||||||
- pip install coverage
|
- pip install coverage
|
||||||
- pip install codecov
|
- pip install codecov
|
||||||
|
- pip install pep8
|
||||||
- pip install -q Django==$DJANGO
|
- pip install -q Django==$DJANGO
|
||||||
- pip install -q -r requirements.txt
|
- pip install -q -r requirements.txt
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- "pep8 --exclude=migrations,south_migrations --ignore=E501 helpdesk"
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- coverage run --source='.' quicktest.py helpdesk
|
- coverage run --source='.' quicktest.py helpdesk
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ You should pass in the keyword argument 'agent' to the name of your program,
|
|||||||
when you create an Akismet instance. This sets the ``user-agent`` to a useful
|
when you create an Akismet instance. This sets the ``user-agent`` to a useful
|
||||||
value.
|
value.
|
||||||
|
|
||||||
The default is : ::
|
The default is::
|
||||||
|
|
||||||
Python Interface by Fuzzyman | akismet.py/0.2.0
|
Python Interface by Fuzzyman | akismet.py/0.2.0
|
||||||
|
|
||||||
@ -203,13 +203,13 @@ class Akismet(object):
|
|||||||
worked out.
|
worked out.
|
||||||
"""
|
"""
|
||||||
data['comment_content'] = comment
|
data['comment_content'] = comment
|
||||||
if not 'user_ip' in data:
|
if 'user_ip' not in data:
|
||||||
try:
|
try:
|
||||||
val = os.environ['REMOTE_ADDR']
|
val = os.environ['REMOTE_ADDR']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
raise AkismetError("No 'user_ip' supplied")
|
raise AkismetError("No 'user_ip' supplied")
|
||||||
data['user_ip'] = val
|
data['user_ip'] = val
|
||||||
if not 'user_agent' in data:
|
if 'user_agent' not in data:
|
||||||
try:
|
try:
|
||||||
val = os.environ['HTTP_USER_AGENT']
|
val = os.environ['HTTP_USER_AGENT']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -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',)
|
||||||
@ -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',)
|
||||||
|
@ -233,7 +233,7 @@ def safe_template_context(ticket):
|
|||||||
|
|
||||||
context = {
|
context = {
|
||||||
'queue': {},
|
'queue': {},
|
||||||
'ticket': {},
|
'ticket': {}
|
||||||
}
|
}
|
||||||
queue = ticket.queue
|
queue = ticket.queue
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
|
@ -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")
|
||||||
|
|
||||||
|
@ -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()
|
||||||
|
@ -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)
|
||||||
|
|
||||||
@ -400,4 +402,3 @@ def ticket_from_message(message, queue, quiet):
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
process_email()
|
process_email()
|
||||||
|
|
||||||
|
@ -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)
|
||||||
|
|
||||||
@ -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')
|
||||||
|
|
||||||
@ -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')
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ class PublicActionsTestCase(TestCase):
|
|||||||
- Add a followup
|
- Add a followup
|
||||||
- Close resolved case
|
- Close resolved case
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
"""
|
"""
|
||||||
Create a queue & ticket we can use for later tests.
|
Create a queue & ticket we can use for later tests.
|
||||||
|
@ -109,6 +109,7 @@ def api_return(status, text='', json=False):
|
|||||||
|
|
||||||
|
|
||||||
class API:
|
class API:
|
||||||
|
|
||||||
def __init__(self, request):
|
def __init__(self, request):
|
||||||
self.request = request
|
self.request = request
|
||||||
|
|
||||||
|
@ -168,4 +168,3 @@ class OpenTicketsByQueue(Feed):
|
|||||||
return item.assigned_to.get_username()
|
return item.assigned_to.get_username()
|
||||||
else:
|
else:
|
||||||
return _('Unassigned')
|
return _('Unassigned')
|
||||||
|
|
||||||
|
@ -299,7 +299,6 @@ def view_ticket(request, ticket_id):
|
|||||||
else:
|
else:
|
||||||
users = User.objects.filter(is_active=True).order_by(User.USERNAME_FIELD)
|
users = User.objects.filter(is_active=True).order_by(User.USERNAME_FIELD)
|
||||||
|
|
||||||
|
|
||||||
# TODO: shouldn't this template get a form to begin with?
|
# TODO: shouldn't this template get a form to begin with?
|
||||||
form = TicketForm(initial={'due_date': ticket.due_date})
|
form = TicketForm(initial={'due_date': ticket.due_date})
|
||||||
|
|
||||||
@ -521,7 +520,7 @@ def update_ticket(request, ticket_id, public=False):
|
|||||||
c.save()
|
c.save()
|
||||||
ticket.due_date = due_date
|
ticket.due_date = due_date
|
||||||
|
|
||||||
if new_status in [ Ticket.RESOLVED_STATUS, Ticket.CLOSED_STATUS ]:
|
if new_status in (Ticket.RESOLVED_STATUS, Ticket.CLOSED_STATUS):
|
||||||
if new_status == Ticket.RESOLVED_STATUS or ticket.resolution is None:
|
if new_status == Ticket.RESOLVED_STATUS or ticket.resolution is None:
|
||||||
ticket.resolution = comment
|
ticket.resolution = comment
|
||||||
|
|
||||||
@ -831,13 +830,12 @@ def ticket_list(request):
|
|||||||
# Query deserialization failed. (E.g. was a pickled query)
|
# Query deserialization failed. (E.g. was a pickled query)
|
||||||
return HttpResponseRedirect(reverse('helpdesk_list'))
|
return HttpResponseRedirect(reverse('helpdesk_list'))
|
||||||
|
|
||||||
elif not ('queue' in request.GET
|
elif not ('queue' in request.GET or
|
||||||
or 'assigned_to' in request.GET
|
'assigned_to' in request.GET or
|
||||||
or 'status' in request.GET
|
'status' in request.GET or
|
||||||
or 'q' in request.GET
|
'q' in request.GET or
|
||||||
or 'sort' in request.GET
|
'sort' in request.GET or
|
||||||
or 'sortreverse' in request.GET
|
'sortreverse' in request.GET):
|
||||||
):
|
|
||||||
|
|
||||||
# Fall-back if no querying is being done, force the list to only
|
# Fall-back if no querying is being done, force the list to only
|
||||||
# show open/reopened/resolved (not closed) cases sorted by creation
|
# show open/reopened/resolved (not closed) cases sorted by creation
|
||||||
@ -1113,7 +1111,8 @@ def run_report(request, report):
|
|||||||
# a second table for more complex queries
|
# a second table for more complex queries
|
||||||
summarytable2 = defaultdict(int)
|
summarytable2 = defaultdict(int)
|
||||||
|
|
||||||
month_name = lambda m: MONTHS_3[m].title()
|
def month_name(m):
|
||||||
|
MONTHS_3[m].title()
|
||||||
|
|
||||||
first_ticket = Ticket.objects.all().order_by('created')[0]
|
first_ticket = Ticket.objects.all().order_by('created')[0]
|
||||||
first_month = first_ticket.created.month
|
first_month = first_ticket.created.month
|
||||||
|
Loading…
x
Reference in New Issue
Block a user