Fix PEP8 errors

This commit is contained in:
Garret Wassermann 2016-10-29 04:08:57 -04:00
parent cad174468b
commit d791700582
5 changed files with 44 additions and 49 deletions

View File

@ -133,7 +133,7 @@ class EditFollowUpForm(forms.ModelForm):
class TicketForm(CustomFieldMixin, forms.Form):
queue = forms.ChoiceField(
widget=forms.Select(attrs={'class':'form-control'}),
widget=forms.Select(attrs={'class': 'form-control'}),
label=_('Queue'),
required=True,
choices=()
@ -142,26 +142,26 @@ class TicketForm(CustomFieldMixin, forms.Form):
title = forms.CharField(
max_length=100,
required=True,
widget=forms.TextInput(attrs={'class':'form-control'}),
widget=forms.TextInput(attrs={'class': 'form-control'}),
label=_('Summary of the problem'),
)
submitter_email = forms.EmailField(
required=False,
label=_('Submitter E-Mail Address'),
widget=forms.TextInput(attrs={'class':'form-control'}),
widget=forms.TextInput(attrs={'class': 'form-control'}),
help_text=_('This e-mail address will receive copies of all public '
'updates to this ticket.'),
)
body = forms.CharField(
widget=forms.Textarea(attrs={'class':'form-control', 'rows': 15}),
widget=forms.Textarea(attrs={'class': 'form-control', 'rows': 15}),
label=_('Description of Issue'),
required=True,
)
assigned_to = forms.ChoiceField(
widget=forms.Select(attrs={'class':'form-control'}),
widget=forms.Select(attrs={'class': 'form-control'}),
choices=(),
required=False,
label=_('Case owner'),
@ -170,7 +170,7 @@ class TicketForm(CustomFieldMixin, forms.Form):
)
priority = forms.ChoiceField(
widget=forms.Select(attrs={'class':'form-control'}),
widget=forms.Select(attrs={'class': 'form-control'}),
choices=Ticket.PRIORITY_CHOICES,
required=False,
initial='3',
@ -179,7 +179,7 @@ class TicketForm(CustomFieldMixin, forms.Form):
)
due_date = forms.DateTimeField(
widget=forms.TextInput(attrs={'class':'form-control'}),
widget=forms.TextInput(attrs={'class': 'form-control'}),
required=False,
label=_('Due on'),
)
@ -539,8 +539,8 @@ class UserSettingsForm(forms.Form):
label=_('Number of tickets to show per page'),
help_text=_('How many tickets do you want to see on the Ticket List page?'),
required=False,
choices=((10,'10'),(25,'25'),(50,'50'),(100,'100')),
)
choices=((10,'10'), (25,'25'), (50,'50'), (100,'100')),
)
use_email_as_submitter = forms.BooleanField(
label=_('Use my e-mail address when submitting tickets?'),
@ -573,6 +573,7 @@ class TicketCCForm(forms.ModelForm):
class TicketCCUserForm(forms.ModelForm):
''' Adds a helpdesk user as a CC on a Ticket '''
def __init__(self, *args, **kwargs):
super(TicketCCUserForm, self).__init__(*args, **kwargs)
if helpdesk_settings.HELPDESK_STAFF_ONLY_TICKET_CC:
@ -582,17 +583,19 @@ class TicketCCUserForm(forms.ModelForm):
self.fields['user'].queryset = users
class Meta:
model = TicketCC
exclude = ('ticket','email',)
exclude = ('ticket', 'email',)
class TicketCCEmailForm(forms.ModelForm):
''' Adds an email address as a CC on a Ticket '''
def __init__(self, *args, **kwargs):
super(TicketCCEmailForm, self).__init__(*args, **kwargs)
class Meta:
model = TicketCC
exclude = ('ticket','user',)
exclude = ('ticket', 'user',)
class TicketDependencyForm(forms.ModelForm):
''' Adds a different ticket as a dependency for this Ticket '''
class Meta:
model = TicketDependency

View File

@ -61,17 +61,6 @@ class Command(BaseCommand):
def __init__(self):
BaseCommand.__init__(self)
# Django 1.7 uses different way to specify options than 1.8+
if VERSION < (1, 8):
self.option_list += (
make_option(
'--quiet',
default=False,
action='store_true',
dest='quiet',
help='Hide details about each queue/message as they are processed'),
)
help = 'Process django-helpdesk queues and process e-mails via POP3/IMAP or ' \
'from a local mailbox directory as required, feeding them into the helpdesk.'
@ -137,8 +126,9 @@ def process_queue(q, logger):
try:
import socks
except ImportError:
no_socks_msg = "Queue has been configured with proxy settings, but no socks " \
"library was installed. Try to install PySocks via PyPI."
no_socks_msg = "Queue has been configured with proxy settings, " \
"but no socks library was installed. Try to " \
"install PySocks via PyPI."
logger.error(no_socks_msg)
raise ImportError(no_socks_msg)

View File

@ -111,7 +111,7 @@ class Queue(models.Model):
email_box_type = models.CharField(
_('E-Mail Box Type'),
max_length=5,
choices=(('pop3', _('POP 3')), ('imap', _('IMAP')), ('local',_('Local Directory'))),
choices=(('pop3', _('POP 3')), ('imap', _('IMAP')), ('local', _('Local Directory'))),
blank=True,
null=True,
help_text=_('E-Mail server type for creating tickets automatically '
@ -178,8 +178,9 @@ class Queue(models.Model):
blank=True,
null=True,
help_text=_('If using a local directory, what directory path do you '
'wish to poll for new email? Example: /var/lib/mail/helpdesk/'),
)
'wish to poll for new email? '
'Example: /var/lib/mail/helpdesk/'),
)
permission_name = models.CharField(
_('Django auth permission name'),
@ -230,14 +231,21 @@ class Queue(models.Model):
logging_type = models.CharField(
_('Logging Type'),
max_length=5,
choices=(('none', _('None')), ('debug', _('Debug')), ('info',_('Information')), ('warn', _('Warning')), ('error', _('Error')), ('crit', _('Critical'))),
max_length = 5,
choices = (
('none', _('None')),
('debug', _('Debug')),
('info', _('Information')),
('warn', _('Warning')),
('error', _('Error')),
('crit', _('Critical'))
),
blank=True,
null=True,
help_text=_('Set the default logging level. All messages at that '
'level or above will be logged to the directory set below. '
'If no level is set, logging will be disabled.'),
)
'level or above will be logged to the directory set '
'below. If no level is set, logging will be disabled.'),
)
logging_dir = models.CharField(
_('Logging Directory'),
@ -245,9 +253,9 @@ class Queue(models.Model):
blank=True,
null=True,
help_text=_('If logging is enabled, what directory should we use to '
'store log files for this queue? '
'If no directory is set, default to /var/log/helpdesk/'),
)
'store log files for this queue? '
'If no directory is set, default to /var/log/helpdesk/'),
)
default_owner = models.ForeignKey(
settings.AUTH_USER_MODEL,

View File

@ -21,7 +21,7 @@ except ImportError:
import mock
class GetEmailTestCase(TestCase):
#fixtures = ['emailtemplate.json'] # may don't need this, not testing templates here
''' Test reading emails from a local directory '''
def setUp(self):
self.queue_public = Queue.objects.create(title='Queue 1', slug='QQ', allow_public_submission=True, allow_email_submission=True, email_box_type='local', email_box_local_dir='/var/lib/mail/helpdesk/')
@ -56,6 +56,3 @@ class GetEmailTestCase(TestCase):
ticket2 = get_object_or_404(Ticket, pk=2)
self.assertEqual(ticket2.ticket_for_url, "QQ-%s" % ticket2.id)
self.assertEqual(ticket2.description, "This is the helpdesk comment via email.")

View File

@ -511,7 +511,7 @@ def update_ticket(request, ticket_id, public=False):
field=_('Status'),
old_value=old_status_str,
new_value=ticket.get_status_display(),
)
)
c.save()
if ticket.assigned_to != old_owner:
@ -520,7 +520,7 @@ def update_ticket(request, ticket_id, public=False):
field=_('Owner'),
old_value=old_owner,
new_value=ticket.assigned_to,
)
)
c.save()
if priority != ticket.priority:
@ -1077,9 +1077,7 @@ def report_index(request):
saved_query = request.GET.get('saved_query', None)
user_queues = _get_user_queues(request.user)
Tickets = Ticket.objects.filter(
queue__in=user_queues,
)
Tickets = Ticket.objects.filter(queue__in=user_queues)
basic_ticket_stats = calc_basic_ticket_stats(Tickets)
# The following query builds a grid of queues & ticket statuses,
@ -1172,8 +1170,7 @@ def run_report(request, report):
periods = []
year, month = first_year, first_month
working = True
#periods.append("%s %s" % (month_name(month), year))
periods.append("%s-%s" % (year,month))
periods.append("%s-%s" % (year, month))
while working:
month += 1
@ -1182,7 +1179,7 @@ def run_report(request, report):
month = 1
if (year > last_year) or (month > last_month and year >= last_year):
working = False
periods.append("%s-%s" % (year,month))
periods.append("%s-%s" % (year, month))
if report == 'userpriority':
title = _('User by Priority')
@ -1298,8 +1295,8 @@ def run_report(request, report):
morrisjs_data = []
for label in column_headings[1:]:
seriesnum += 1
datadict = { "x": label }
for n in range(0,len(table)):
datadict = {"x": label}
for n in range(0, len(table)):
datadict[n] = table[n][seriesnum]
morrisjs_data.append(datadict)