Anonymous avatar Anonymous committed b23bd91

Code style updates (PEP8)

Comments (0)

Files changed (4)

licenses/admin.py

 from django.utils.translation import ugettext_lazy as _
 from licenses.models import Organization, License
 
+
 class OrganizationAdmin(admin.ModelAdmin):
 	prepopulated_fields = {'slug': ('name', )}
 	list_display = ('name', 'abbreviation', 'website')
-	search_fields = ('name', 'slug', 'abbreviation','website', 'description')
+	search_fields = ('name', 'slug', 'abbreviation', 'website', 'description')
+
 
 class LicenseAdmin(admin.ModelAdmin):
 	prepopulated_fields = {'slug': ('name', )}
 	radio_fields = {'organization': admin.HORIZONTAL}
 	fieldsets = (
 		(None, {
-			'fields': ('name', 'slug', 'url', 'abbreviation', 'organization')
+			'fields': ('name', 'slug', 'url', 'abbreviation', 'organization'),
 		}),
 		(_('Advanced options'), {
-			'classes': ('collapse',),
-			'fields': ('logo', 'description', 'is_active')
+			'classes': ('collapse', ),
+			'fields': ('logo', 'description', 'is_active'),
 		}),
 	)
 
+
 admin.site.register(Organization, OrganizationAdmin)
 admin.site.register(License, LicenseAdmin)

licenses/fields.py

 from django.utils.translation import ugettext_lazy as _
 from licenses.models import License
 
+
 class LicenseField(ForeignKey):
+	'''
+		A ForeignKey field with default value for verbose_name
+		and a shortcut for switching blank/null to True.
+	'''
+
 	def __init__(self, **kwargs):
 		kwargs.setdefault('verbose_name', _('license'))
 		if kwargs.pop('required', None) == False:

licenses/models.py

 from django.db.models import Model, CharField, SlugField, URLField, TextField, ForeignKey, BooleanField
 from django.utils.translation import ugettext_lazy as _
 
+
 class Organization(Model):
 	'''
 		Organization/Authors of licenses.
 
 	class Meta:
 		db_table = 'licenses_organization'
-		ordering  = ('name', )
+		ordering = ('name', )
 		verbose_name = _('organization')
 		verbose_name_plural = _('organizations')
 
 	def url(self):
 		return self.website
 
+
 class License(Model):
 	'''
 		A license.
 
 	class Meta:
 		db_table = 'licenses_license'
-		ordering  = ('name', )
+		ordering = ('name', )
 		verbose_name = _('license')
 		verbose_name_plural = _('licenses')

licenses/templatetags/licensing.py

 
 register = template.Library()
 
+
 class GetLicenseNode(template.Node):
+	'''
+		Generic node to get one license, the tag defines the search paramter.
+	'''
+
 	@classmethod
 	def handle_token(cls, parser, token):
 		tokens = token.contents.split()
 		if len(tokens) == 4:
 			if tokens[2] != 'as':
-				raise template.TemplateSyntaxError("Second argument in %r must be 'as'" % tokens[0])
+				raise template.TemplateSyntaxError("Second argument in %s must be 'as'" % tokens[0])
 			return cls(
 				abbr = tokens[1][1:-1], # TODO: not a safe parser for quotes
 				varname = tokens[3],
 		context[self.varname] = license
 		return ''
 
+
 # TODO: add get_license_by_slug, etc
 @register.tag
 def get_license_by_abbr(parser, token):
 	'''
 	return GetLicenseNode.handle_token(parser, token)
 
+
+# TODO: ?? put html into template?
 @register.filter
 def license_link(license):
 	'''
 	}
 	return mark_safe('<a rel="license" href="%(url)s">%(name)s</a>' % data)
 
+
 @register.filter
 def license_logo(license):
 	'''
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.