Permalink
Browse files

PEP 8 updates

  • Loading branch information...
1 parent ab2a4b7 commit 251b2fd0b8a08d94b7b953cec190390377fe1be2 @archen archen committed Mar 1, 2014
Showing with 19 additions and 9 deletions.
  1. +6 −2 tekextensions/context_processors.py
  2. +5 −4 tekextensions/forms.py
  3. +4 −3 tekextensions/views.py
  4. +4 −0 tekextensions/widgets.py
View
8 tekextensions/context_processors.py
@@ -1,13 +1,17 @@
from django.conf import settings
from django.contrib.sites.models import Site, RequestSite
+
def admin_media_prefix(request):
return {'ADMIN_MEDIA_PREFIX': settings.ADMIN_MEDIA_PREFIX }
+
def current_site(request):
- '''
+ """
A context processor to add the "current_site" to the current Context
- '''
+
+ """
+
context_name = 'CURRENT_SITE'
try:
View
9 tekextensions/forms.py
@@ -1,14 +1,16 @@
from django.forms.models import modelform_factory
-from django.db.models.loading import get_models, get_app, get_apps
+from django.db.models.loading import get_models, get_apps
+
def normalize_model_name(model_name):
- if (model_name.lower() == model_name):
+ if model_name.lower() == model_name:
normal_model_name = model_name.capitalize()
else:
normal_model_name = model_name
return normal_model_name
+
def get_model_form(model_name):
app_list = get_apps()
for app in app_list:
@@ -17,5 +19,4 @@ def get_model_form(model_name):
form = modelform_factory(model)
return form
- raise Exception('Did not find the model %s' % (model_name))
-
+ raise Exception('Did not find the model %s' % model_name)
View
7 tekextensions/views.py
@@ -5,6 +5,7 @@
from django.forms import ValidationError
from tekextensions.forms import get_model_form, normalize_model_name
+
def add_new_model(request, model_name, form=None):
normal_model_name = normalize_model_name(model_name)
@@ -20,12 +21,12 @@ def add_new_model(request, model_name, form=None):
new_obj = None
if new_obj:
- return HttpResponse('<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' % \
+ return HttpResponse(
+ '<script type="text/javascript">opener.dismissAddAnotherPopup(window, "%s", "%s");</script>' %
(escape(new_obj._get_pk_val()), escape(new_obj)))
else:
form = form()
page_context = {'form': form, 'field': normal_model_name}
- return render_to_response('popup.html', page_context, context_instance=RequestContext(request))
-
+ return render_to_response('popup.html', page_context, context_instance=RequestContext(request))
View
4 tekextensions/widgets.py
@@ -2,6 +2,7 @@
from django.template.loader import render_to_string
from django.contrib.admin.widgets import FilteredSelectMultiple
+
class PopUpBaseWidget(object):
def __init__(self, model=None, template='addnew.html', *args, **kwargs):
self.model = model
@@ -25,11 +26,14 @@ def _media(self):
)
media = property(_media)
+
class FilteredMultipleSelectWithPopUp(PopUpBaseWidget, FilteredSelectMultiple):
pass
+
class MultipleSelectWithPopUp(PopUpBaseWidget, forms.SelectMultiple):
pass
+
class SelectWithPopUp(PopUpBaseWidget, forms.Select):
pass

0 comments on commit 251b2fd

Please sign in to comment.