aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Doan <doanac@beadoan.com>2014-07-31 14:11:43 +0000
committerAndy Doan <doanac@beadoan.com>2014-07-31 14:12:53 +0000
commit755f9fb776c5bcc54e73d6bd22b050ef62dba7a6 (patch)
tree81e1c3849124e46a3e1930874cc3ed83169d024c
parentbf49b11a56a0e734484446c771c05e54787d2bcc (diff)
downloadlinaro-android-frontend-755f9fb776c5bcc54e73d6bd22b050ef62dba7a6.tar.gz
pep8 fixes
also add a .gitignore Change-Id: I8524b18cb5c70a5b4f81b31653f93b56b071d664
-rw-r--r--.gitignore3
-rw-r--r--android_build/frontend/views.py19
2 files changed, 14 insertions, 8 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..000a159
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.pyc
+*.swp
+session.db
diff --git a/android_build/frontend/views.py b/android_build/frontend/views.py
index 40a2e46..24a4d41 100644
--- a/android_build/frontend/views.py
+++ b/android_build/frontend/views.py
@@ -3,12 +3,11 @@ from django.http import HttpResponse
from django.template import RequestContext
from django.shortcuts import (
render_to_response,
- )
+)
from django.contrib.auth.decorators import (
login_required
)
from django.contrib.auth.models import Group
-import simplejson as json
config_template = '''\
@@ -17,11 +16,12 @@ var globalConfig = {
}
'''
+
def get_username(request):
return request.user.username.split("@", 1)[0]
+
def prefix2group(prefix):
- rev_map = {}
# If prefix is in adhoc map, return corresponding group
for k, v in settings.GROUP_TO_PREFIX_MAP.iteritems():
if v == prefix:
@@ -32,15 +32,18 @@ def prefix2group(prefix):
# Otherwise, it should be personal build
return "linaro-android-builders"
+
def group2prefix(request, group):
val = settings.GROUP_TO_PREFIX_MAP.get(group, group)
if val == "$user":
return get_username(request)
return val
+
def is_builder(request):
return request.user.groups.filter(name='linaro-android-builders').exists()
+
def can_edit(request, build_name):
if request.user.is_authenticated():
owner_name = build_name.split('/')[0][1:]
@@ -63,7 +66,7 @@ def _config(request):
data['userGroups'] = repr(str(' '.join(gl)))
else:
data['userName'] = 'null'
- data['userGroups'] = 'null'
+ data['userGroups'] = 'null'
data['jenkinsURL'] = repr(settings.JENKINS_URL_FOR_APP)
data['loginURL'] = repr(settings.LOGIN_URL)
l = []
@@ -76,7 +79,7 @@ def _render(request, filename, data=None):
context_data = {
'config_data': _config(request),
'useOwnCombo': settings.USE_OWN_COMBO,
- }
+ }
if data is not None:
context_data.update(data)
response = render_to_response(
@@ -84,7 +87,7 @@ def _render(request, filename, data=None):
context_instance=RequestContext(request))
response.set_cookie(
settings.CSRF_COOKIE_NAME, request.META["CSRF_COOKIE"],
- max_age = 60 * 60 * 24 * 7 * 52, domain=settings.CSRF_COOKIE_DOMAIN)
+ max_age=60 * 60 * 24 * 7 * 52, domain=settings.CSRF_COOKIE_DOMAIN)
return response
@@ -97,7 +100,7 @@ def build_details(request, buildName):
'buildName': buildName,
'canEdit': can_edit(request, buildName),
'canBuild': is_builder(request),
- }
+ }
return _render(request, 'buildDetails.html', data)
@@ -109,5 +112,5 @@ def new(request):
'request': request,
'user': get_username(request),
'groups': request.user.groups.all(),
- }
+ }
return _render(request, 'new.html', data)