Skip to content

Commit a80db4d

Browse files
committed
Conform all python files with PEP8 by moving long code lines to new line.
1 parent a3b32ae commit a80db4d

File tree

10 files changed

+83
-65
lines changed

10 files changed

+83
-65
lines changed

accounts/urls.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
from django.conf.urls import url
22
from . import views
3-
from accounts.views import index, logout, login, registration, user_profile, user_list, update_first_name, update_last_name, update_zoomid, grant_staff_access
3+
from accounts.views import (index, logout, login, registration, user_profile,
4+
user_list, update_first_name, update_last_name,
5+
update_zoomid, grant_staff_access)
46

57
urlpatterns = [
68
url(r'^logout/$', logout, name='logout'),

accounts/views.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ def update_zoomid(request, pk):
145145
def grant_staff_access(request, pk):
146146
"""Allows Code Institute assessors to be immediately granted Staff Access.
147147
This is to ensure Assessors can see the full feature set.
148-
In a non-assessment situation, clicking Request Staff Access link would send email to Admin,
149-
who could then set is_staff to True
148+
In a non-assessment situation, clicking Request Staff Access link would
149+
send email to Admin, who could then set is_staff to True.
150150
"""
151151
user = get_object_or_404(User, pk=pk)
152152
if request.method == 'POST':
@@ -157,5 +157,6 @@ def grant_staff_access(request, pk):
157157
user.is_staff = True
158158
user.save()
159159
messages.success(
160-
request, "You have been granted Staff Access as a CI Assessor. You can now edit all tickets.")
160+
request, ("You have been granted Staff Access as a CI Assessor."
161+
"You can now edit all tickets."))
161162
return redirect(user_profile)

checkout/forms.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,16 @@ class Meta:
2424
model = Order
2525
widgets = {
2626
'full_name': forms.TextInput(attrs={'placeholder': 'Full Name'}),
27-
'street_address1': forms.TextInput(attrs={'placeholder': 'Street Address (line 1)'}),
28-
'street_address2': forms.TextInput(attrs={'placeholder': 'Street Address (line 2)'}),
29-
'town_or_city': forms.TextInput(attrs={'placeholder': 'Town/City'}),
27+
'street_address1': forms.TextInput(
28+
attrs={'placeholder': 'Street Address (line 1)'}),
29+
'street_address2': forms.TextInput(
30+
attrs={'placeholder': 'Street Address (line 2)'}),
31+
'town_or_city': forms.TextInput(
32+
attrs={'placeholder': 'Town/City'}),
3033
'county': forms.TextInput(attrs={'placeholder': 'County'}),
3134
'country': forms.TextInput(attrs={'placeholder': 'Country'}),
32-
'phone_number': forms.TextInput(attrs={'placeholder': 'Phone Number'}),
35+
'phone_number': forms.TextInput(
36+
attrs={'placeholder': 'Phone Number'}),
3337
'postcode': forms.TextInput(attrs={'placeholder': 'Postcode'})
3438
}
3539
fields = (

checkout/views.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ def checkout(request):
5050
user.save()
5151
messages.success(
5252
request, "You have successfully paid. Enjoy PRO!")
53-
# request.session['cart'] = {}
5453

5554
return redirect(reverse('profile'))
5655
else:
@@ -63,4 +62,7 @@ def checkout(request):
6362
payment_form = MakePaymentForm()
6463
order_form = OrderForm()
6564

66-
return render(request, "checkout.html", {'order_form': order_form, 'payment_form': payment_form, 'publishable': settings.STRIPE_PUBLISHABLE})
65+
return render(request, "checkout.html",
66+
{'order_form': order_form,
67+
'payment_form': payment_form,
68+
'publishable': settings.STRIPE_PUBLISHABLE})

issue_tracker/settings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
'django.contrib.contenttypes',
3434
'django.contrib.sessions',
3535
'django.contrib.messages',
36-
'livereload',
36+
# 'livereload',
3737
'django.contrib.staticfiles',
3838
'django_forms_bootstrap',
3939
'accounts',
@@ -55,7 +55,7 @@
5555
'django.contrib.messages.middleware.MessageMiddleware',
5656
'django.middleware.clickjacking.XFrameOptionsMiddleware',
5757
'simple_history.middleware.HistoryRequestMiddleware',
58-
'livereload.middleware.LiveReloadScript',
58+
# 'livereload.middleware.LiveReloadScript',
5959
]
6060

6161
ROOT_URLCONF = 'issue_tracker.urls'
@@ -80,7 +80,7 @@
8080

8181
# Database
8282

83-
if "DATABASE_URL" in os.environ and development == False:
83+
if "DATABASE_URL" in os.environ and development is False:
8484
print('Database URL found. Using POSTGRESQL')
8585
DATABASES = {
8686
'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))

issue_tracker/urls.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,12 @@
1-
"""issue_tracker URL Configuration
1+
"""issue_tracker URL Configuration"""
22

3-
The `urlpatterns` list routes URLs to views. For more information please see:
4-
https://docs.djangoproject.com/en/1.11/topics/http/urls/
5-
Examples:
6-
Function views
7-
1. Add an import: from my_app import views
8-
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
9-
Class-based views
10-
1. Add an import: from other_app.views import Home
11-
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
12-
Including another URLconf
13-
1. Import the include() function: from django.conf.urls import url, include
14-
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
15-
"""
163
from django.conf.urls import url, include
174
from django.contrib import admin
185
from django.conf import settings
196
from django.conf.urls.static import static
207
from accounts.views import index
218

9+
2210
urlpatterns = [
2311
url(r'^$', index, name='index'),
2412
url(r'^admin/', admin.site.urls),

issue_tracker/wsgi.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
WSGI config for issue_tracker project.
33
44
It exposes the WSGI callable as a module-level variable named ``application``.
5-
6-
For more information on this file, see
7-
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
85
"""
96

107
import os

tickets/forms.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ class Meta:
1919
model = Ticket
2020
widgets = {
2121
'summary': forms.TextInput(attrs={'placeholder': 'Summary'}),
22-
'description': forms.Textarea(attrs={'placeholder': 'Add a description',
23-
'rows': 4}),
22+
'description': forms.Textarea(
23+
attrs={'placeholder': 'Add a description',
24+
'rows': 4}),
2425
}
2526
fields = ('ticket_type', 'summary',
2627
'description', 'priority',
@@ -39,7 +40,11 @@ class Meta:
3940
model = Ticket
4041
widgets = {
4142
'summary': forms.TextInput(attrs={'placeholder': 'Summary'}),
42-
'description': forms.Textarea(attrs={'placeholder': 'Add a description', 'rows': 4}),
43+
'description': forms.Textarea(
44+
attrs={
45+
'placeholder': 'Add a description',
46+
'rows': 4
47+
}),
4348
}
4449
fields = ('ticket_type', 'summary',
4550
'description', 'priority',
@@ -52,7 +57,8 @@ class Meta:
5257
model = Comment
5358
fields = ('comment_body',)
5459
widgets = {
55-
'comment_body': forms.Textarea(attrs={'placeholder': 'Leave a comment', 'rows': 2})
60+
'comment_body': forms.Textarea(
61+
attrs={'placeholder': 'Leave a comment', 'rows': 2})
5662
}
5763
labels = {
5864
'comment_body': '',

tickets/models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ def age(self):
4040

4141
def days_to_resolve(self):
4242
if self.resolved_date:
43-
return int((self.resolved_date.date() - self.created_date.date()).days)
43+
return int(
44+
(self.resolved_date.date() - self.created_date.date()).days
45+
)
4446
else:
4547
return None
4648

tickets/views.py

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
1+
from accounts.models import Profile
2+
import datetime
13
from django.shortcuts import render, get_object_or_404, redirect
24
from django.http import HttpResponse, JsonResponse
35
from django.contrib import messages
46
from django.contrib.auth.decorators import login_required
5-
from django.db.models import Q, Sum, Count
6-
from .models import Ticket, Comment, HistoricalTicket
7-
from accounts.models import Profile
87
from django.contrib.auth.models import User
9-
from .forms import AddTicketForm, AddCommentForm, EditTicketForm
8+
from django.db.models import Q, Sum, Count
9+
from django.utils.safestring import mark_safe
1010
from rest_framework import viewsets
11+
from .forms import AddTicketForm, AddCommentForm, EditTicketForm
12+
from .models import Ticket, Comment, HistoricalTicket
1113
from .serializers import TicketSerializer
12-
from django.utils.safestring import mark_safe
13-
import datetime
1414

1515

16-
# Django REST API
1716
class RestView(viewsets.ModelViewSet):
17+
"""Django REST API as data source for Dashboard page"""
1818
queryset = Ticket.objects.all()
1919
serializer_class = TicketSerializer
2020

21-
# Dashboard
21+
2222
@login_required()
2323
def dashboard(request):
24+
"""Renders Dashboard page with 6 charts"""
2425
return render(request, 'dashboard.html')
2526

26-
# View Tickets
27+
2728
@login_required()
2829
def view_tickets(request):
29-
"""Display All Tickets"""
30+
"""Renders Tickets page with data table of all tickets"""
3031
tickets = Ticket.objects.filter()
3132
return render(request, 'tickets.html', {'tickets': tickets})
3233

33-
# View Single Ticket
34+
3435
@login_required()
3536
def view_ticket(request, pk):
36-
"""Display single ticket details, change history and comments"""
37+
"""View single ticket details, change history and comments"""
3738
ticket = get_object_or_404(Ticket, pk=pk) if pk else None
3839
# Change History
3940
historical_changes = HistoricalTicket.objects.filter(id=pk)
@@ -44,7 +45,6 @@ def view_ticket(request, pk):
4445
delta = new_record.diff_against(old_record)
4546
for change in delta.changes:
4647
if (change.field != 'upvotes'):
47-
# if (change.field != 'upvotes' and change.field != 'image'):
4848
test_change = {
4949
'field': change.field,
5050
'new_value': change.new,
@@ -62,7 +62,9 @@ def view_ticket(request, pk):
6262
if form.is_valid():
6363
comment_body = form.cleaned_data.get("comment_body")
6464
comment = Comment(
65-
ticket_id=pk, comment_body=comment_body, user_id=request.user.id)
65+
ticket_id=pk,
66+
comment_body=comment_body,
67+
user_id=request.user.id)
6668
comment.save()
6769
messages.info(request, "Comment submitted.")
6870
return redirect(view_ticket, pk)
@@ -75,23 +77,32 @@ def view_ticket(request, pk):
7577
@login_required()
7678
def add_ticket(request, pk=None):
7779
"""User Adds Ticket (Bug or Feature)"""
78-
# If user has BASIC account, check if user has reached 10 ticket submission limit in current month
80+
"""If user has BASIC account, check if user has reached 10 ticket
81+
submission limit in current month"""
7982
user = get_object_or_404(User, id=request.user.id)
8083
user_profile = get_object_or_404(Profile, user_id=request.user.id)
8184
if not user_profile.is_pro_user:
8285
today = datetime.datetime.today()
8386
start_date = datetime.datetime(today.year, today.month, 1)
8487
end_date = datetime.datetime(
85-
today.year + int(today.month / 12), ((today.month % 12) + 1), 1)
88+
today.year + int(today.month / 12),
89+
((today.month % 12) + 1), 1)
8690
tickets_submitted_this_month = Ticket.objects.filter(
87-
submitted_by_id=user, created_date__range=(start_date, end_date)).count()
91+
submitted_by_id=user,
92+
created_date__range=(start_date, end_date)).count()
8893
if tickets_submitted_this_month > 9:
8994
messages.warning(
90-
request, "You have reached the 10 ticket monthly limit - Go PRO for unlimited tickets.")
95+
request, ("You have reached the 10 ticket monthly limit"
96+
" - Go PRO for unlimited tickets."))
9197
return redirect('checkout')
9298
else:
9399
messages.info(
94-
request, mark_safe("Note: You have submitted <b>" + str(tickets_submitted_this_month) + "</b> of <b>10</b> free tickets this month. <a href='/checkout/'>Go PRO</a> for unlimited."))
100+
request, mark_safe(
101+
("Note: You have submitted <b>" +
102+
str(tickets_submitted_this_month) +
103+
"</b> of <b>10</b> free tickets this month."
104+
" <a href='/checkout/'>Go PRO</a> for unlimited."
105+
)))
95106
ticket = get_object_or_404(Ticket, pk=pk) if pk else None
96107

97108
if (request.method == "POST"):
@@ -111,7 +122,7 @@ def add_ticket(request, pk=None):
111122

112123
@login_required()
113124
def upvote(request, pk=None):
114-
"""Upvote a Ticket"""
125+
"""Upvote a Ticket. Increments upvotes by 1."""
115126
ticket = get_object_or_404(Ticket, pk=pk) if pk else None
116127
if (request.method == "POST"):
117128
# Increment upvotes by 1
@@ -129,21 +140,25 @@ def edit_ticket(request, pk=None):
129140
if (request.method == "POST"):
130141
form = EditTicketForm(request.POST, request.FILES, instance=ticket)
131142
if form.is_valid():
132-
if ticket.status == 'Resolved' and ticket.resolved_date != None:
133-
# If ticket is set to resolved for the first time, set resolved date to now
143+
if (ticket.status == 'Resolved' and
144+
ticket.resolved_date is not None):
145+
# If ticket is set to resolved for the first time,
146+
# set resolved date to now
134147
ticket.resolved_date = datetime.datetime.now()
135148
ticket = form.save()
136149
messages.info(
137150
request, "Ticket Updated | " + str(ticket.id))
138151
return redirect(view_tickets)
139152
else:
140153
form = EditTicketForm(instance=ticket)
141-
return render(request, 'edit_ticket.html', {'form': form, 'ticket': ticket})
154+
return render(request, 'edit_ticket.html',
155+
{'form': form, 'ticket': ticket})
142156

143157

144158
@login_required()
145159
def kanban(request):
146-
"""Show KANBAN View (PRO Feature)"""
160+
"""Show tickets in KANBAN View with columns
161+
representing ticket status (PRO Feature)"""
147162
# Ensure user is PRO user
148163
user = get_object_or_404(Profile, user_id=request.user.id)
149164
if not user.is_pro_user:
@@ -160,12 +175,13 @@ def kanban(request):
160175
status='Resolved')
161176
cancelled_tickets = tickets.filter(
162177
status='Cancelled')
163-
return render(request, 'kanban.html', {'tickets': tickets,
164-
'new_tickets': new_tickets,
165-
'in_progress_tickets': in_progress_tickets,
166-
'resolved_tickets': resolved_tickets,
167-
'cancelled_tickets': cancelled_tickets,
168-
})
178+
return render(request, 'kanban.html',
179+
{'tickets': tickets,
180+
'new_tickets': new_tickets,
181+
'in_progress_tickets': in_progress_tickets,
182+
'resolved_tickets': resolved_tickets,
183+
'cancelled_tickets': cancelled_tickets,
184+
})
169185

170186

171187
@login_required()

0 commit comments

Comments
 (0)