Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide.
authorPawel Solyga <Pawel.Solyga@gmail.com>
Sat, 24 Jan 2009 12:54:59 +0000
changeset 959 b6e8750c9407
parent 958 b4309e3cb899
child 960 129efa976d6d
Some style guide fixes, docstring fixes and removal of unused imports in different modules. Rename acceptInvite view variable to accept_invite in soc.views.models.host module to comply to our style guide. Patch by: Pawel Solyga Review by: to-be-reviewed
app/soc/models/request.py
app/soc/views/helper/templatetags/forms_helpers.py
app/soc/views/models/host.py
app/soc/views/models/role.py
--- a/app/soc/models/request.py	Sat Jan 24 12:51:47 2009 +0000
+++ b/app/soc/models/request.py	Sat Jan 24 12:54:59 2009 +0000
@@ -52,7 +52,6 @@
   #           the user access to create the role
   state = db.StringProperty(required=True, default='new',
       choices=['new', 'group_accepted', 'completed', 'rejected','ignored'])
-  state.help_text = ugettext_lazy(
-      'Shows the state of the request')
+  state.help_text = ugettext_lazy('Shows the state of the request')
 
 
--- a/app/soc/views/helper/templatetags/forms_helpers.py	Sat Jan 24 12:51:47 2009 +0000
+++ b/app/soc/views/helper/templatetags/forms_helpers.py	Sat Jan 24 12:54:59 2009 +0000
@@ -138,7 +138,7 @@
 
 
 def get_reference_url(form, name):
-  """Retrieves the reference url from a field
+  """Retrieves the reference url from a field.
 
   Args:
     form: the form the field is defined in
--- a/app/soc/views/models/host.py	Sat Jan 24 12:51:47 2009 +0000
+++ b/app/soc/views/models/host.py	Sat Jan 24 12:54:59 2009 +0000
@@ -31,7 +31,6 @@
 from soc.logic.models import host as host_logic
 from soc.logic.models import user as user_logic
 from soc.logic.models import sponsor as sponsor_logic
-from soc.views import helper
 from soc.views.helper import access
 from soc.views.helper import dynaform
 from soc.views.helper import widgets
@@ -85,10 +84,10 @@
     new_params['create_extra_dynafields'] = {
        'scope_path': forms.CharField(widget=forms.HiddenInput,
                                   required=True),
-       'clean_link_id' : cleaning.clean_existing_user('link_id'),
-       'clean_home_page' : cleaning.clean_url('home_page'),
-       'clean_blog' : cleaning.clean_url('blog'),
-       'clean_photo_url' : cleaning.clean_url('photo_url')}
+       'clean_link_id': cleaning.clean_existing_user('link_id'),
+       'clean_home_page': cleaning.clean_url('home_page'),
+       'clean_blog': cleaning.clean_url('blog'),
+       'clean_photo_url': cleaning.clean_url('photo_url')}
 
     params = dicts.merge(params, new_params)
 
@@ -137,7 +136,7 @@
     super(View, self)._editPost(request, entity, fields)
 
   def _acceptInvitePost(self, fields, request, context, params, **kwargs):
-    """Fills in the fields that were missing in the invited_created_form
+    """Fills in the fields that were missing in the invited_created_form.
     
     For params see base.View._acceptInvitePost()
     """
@@ -148,7 +147,7 @@
 
 view = View()
 
-acceptInvite = view.acceptInvite
+accept_invite = view.acceptInvite
 create = view.create
 delete = view.delete
 edit = view.edit
--- a/app/soc/views/models/role.py	Sat Jan 24 12:51:47 2009 +0000
+++ b/app/soc/views/models/role.py	Sat Jan 24 12:54:59 2009 +0000
@@ -24,22 +24,16 @@
 
 
 from django import http
-from django import forms
 from django.utils.translation import ugettext_lazy
 
 from soc.logic import dicts
 from soc.logic.models import request as request_logic
-from soc.logic.models import user as user_logic
 from soc.logic.helper import request as request_helper
-from soc.views import helper
-from soc.views import out_of_band
-from soc.views.helper import access
 from soc.views.helper import decorators
 from soc.views.helper import redirects
 from soc.views.helper import responses
 from soc.views.models import base
 from soc.views.models import request as request_view
-from soc.views.models import user as user_view
 
 import soc.models.request
 import soc.views.helper.lists
@@ -109,13 +103,13 @@
 
     Args:
       request: the standard Django HTTP request object
-      page_name: the page name displayed in templates as page and header title
+      context: dictionary containing the context for this view
       params: a dict with params for this View
       kwargs: the Key Fields for the specified entity
     """
 
     # set the role to the right name
-    fields = {'role' : '%(module_name)s' %(params)}
+    fields = {'role': '%(module_name)s' % (params)}
 
     # get the request view parameters and initialize the create form
     request_params = request_view.view.getParams()
@@ -149,15 +143,15 @@
     key_name, form_fields = soc.views.helper.forms.collectCleanedFields(form)
     
     # get the group entity for which this request is via the scope_path
-    group_key_fields = kwargs['scope_path'].rsplit('/',1)
+    group_key_fields = kwargs['scope_path'].rsplit('/', 1)
     
     if len(group_key_fields) == 1:
       # there is only a link_id
-      fields = {'link_id' : group_key_fields[0]}
+      fields = {'link_id': group_key_fields[0]}
     else:
       # there is a scope_path and link_id
-      fields = {'scope_path' : group_key_fields[0],
-                'link_id' : group_key_fields[1]}
+      fields = {'scope_path': group_key_fields[0],
+                'link_id': group_key_fields[1]}
     
     group = params['group_logic'].getForFields(fields, unique=True)
     
@@ -167,24 +161,24 @@
       request_scope_path = group.link_id
 
     # create the fields for the new request entity
-    request_fields = {'link_id' : form_fields['link_id'].link_id,
-        'scope' : group,
-        'scope_path' : request_scope_path,
-        'role' : params['module_name'],
-        'role_verbose' : params['name'],
-        'state' : 'group_accepted'}
+    request_fields = {'link_id': form_fields['link_id'].link_id,
+        'scope': group,
+        'scope_path': request_scope_path,
+        'role': params['module_name'],
+        'role_verbose': params['name'],
+        'state': 'group_accepted'}
 
     # extract the key_name for the new request entity
     key_fields = request_logic.logic.getKeyFieldsFromDict(request_fields)
     key_name = request_logic.logic.getKeyNameForFields(key_fields)
 
     # create the request entity
-    entity = request_logic.logic.updateOrCreateFromKeyName(request_fields, key_name)
+    entity = request_logic.logic.updateOrCreateFromKeyName(request_fields, 
+        key_name)
     
     # TODO(ljvderijk) redirect to a more useful place like the group homepage
     return http.HttpResponseRedirect('/')
 
-
   @decorators.merge_params
   @decorators.check_access
   def acceptInvite(self, request, access_type,
@@ -194,7 +188,7 @@
     Args:
       request: the standard Django HTTP request object
       access_type : the name of the access type which should be checked
-      context: dictionary containing the context for this view
+      page_name: the page name displayed in templates as page and header title
       params: a dict with params for this View
       kwargs: the Key Fields for the specified entity
     """
@@ -220,9 +214,10 @@
       kwargs: the Key Fields for the specified entity
     """
 
-    # create the form using the scope_path and link_id from kwargs as initial value
-    fields = {'link_id' : kwargs['link_id'],
-              'scope_path' : kwargs['scope_path']}
+    # create the form using the scope_path and link_id from kwargs 
+    # as initial value
+    fields = {'link_id': kwargs['link_id'],
+              'scope_path': kwargs['scope_path']}
     form = params['invited_create_form'](initial=fields)
 
     # construct the appropriate response
@@ -275,9 +270,8 @@
     # redirect to the roles overview page
     return http.HttpResponseRedirect('/user/roles')
 
-
   def _acceptInvitePost(self, fields, request, context, params, **kwargs):
-    """ Used to post-process data after the fields have been cleaned.
+    """Used to post-process data after the fields have been cleaned.
 
       Args:
       fields : the cleaned fields from the role form