Jannis Leidel avatar Jannis Leidel committed 39c47b9

Tab to spaces conversion

Comments (0)

Files changed (4)

licenses/admin.py

 
 
 class OrganizationAdmin(ModelAdmin):
-	prepopulated_fields = {'slug': ('name', )}
-	list_display = ('name', 'abbreviation', 'website')
-	search_fields = ('name', 'slug', 'abbreviation', 'website', 'description')
+    prepopulated_fields = {'slug': ('name', )}
+    list_display = ('name', 'abbreviation', 'website')
+    search_fields = ('name', 'slug', 'abbreviation', 'website', 'description')
 site.register(Organization, OrganizationAdmin)
 
 
 class LicenseAdmin(ModelAdmin):
-	prepopulated_fields = {'slug': ('name', )}
-	list_display = ('name', 'abbreviation', 'organization', 'is_active')
-	list_filter = ('is_active', )
-	search_fields = ('name', 'slug', 'abbreviation', 'url', 'description')
-	radio_fields = {'organization': HORIZONTAL}
-	fieldsets = (
-		(None, {
-			'fields': ('name', 'slug', 'url', 'abbreviation', 'organization'),
-		}),
-		(_('Advanced options'), {
-			'classes': ('collapse', ),
-			'fields': ('logo', 'description', 'is_active'),
-		}),
-	)
+    prepopulated_fields = {'slug': ('name', )}
+    list_display = ('name', 'abbreviation', 'organization', 'is_active')
+    list_filter = ('is_active', )
+    search_fields = ('name', 'slug', 'abbreviation', 'url', 'description')
+    radio_fields = {'organization': HORIZONTAL}
+    fieldsets = (
+        (None, {
+            'fields': ('name', 'slug', 'url', 'abbreviation', 'organization'),
+        }),
+        (_('Advanced options'), {
+            'classes': ('collapse', ),
+            'fields': ('logo', 'description', 'is_active'),
+        }),
+    )
 site.register(License, LicenseAdmin)

licenses/fields.py

 
 
 class LicenseField(ForeignKey):
-	'''
-		A ForeignKey field with default value for verbose_name
-		and a shortcut for switching blank/null to True.
-	'''
+    '''
+        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:
-			kwargs['blank'] = True
-			kwargs['null'] = True
-		ForeignKey.__init__(self, 'licenses.License', **kwargs)
+    def __init__(self, **kwargs):
+        kwargs.setdefault('verbose_name', _('license'))
+        if kwargs.pop('required', None) == False:
+            kwargs['blank'] = True
+            kwargs['null'] = True
+        ForeignKey.__init__(self, 'licenses.License', **kwargs)

licenses/models.py

 
 
 class Organization(Model):
-	'''
-		Organization/Authors of licenses.
-	'''
-	name = CharField(_('name'), max_length = 100, unique = True,
-		help_text = _('The complete name of a organization which is resposible for a license.'))
-	slug = SlugField(_('slug'), unique = True)
-	abbreviation = CharField(_('abbreviation'), max_length = 50, blank = True,
-		help_text = _('The short name of the organization.'))
-	website = URLField(_('website'), verify_exists = True,
-		help_text = _('The website of the organization.'))
-	description = TextField(_('description'), blank = True,
-		help_text = _('Additional information about the organization, that is not covered by the above fields.'))
+    '''
+        Organization/Authors of licenses.
+    '''
+    name = CharField(_('name'), max_length = 100, unique = True,
+        help_text = _('The complete name of a organization which is resposible for a license.'))
+    slug = SlugField(_('slug'), unique = True)
+    abbreviation = CharField(_('abbreviation'), max_length = 50, blank = True,
+        help_text = _('The short name of the organization.'))
+    website = URLField(_('website'), verify_exists = True,
+        help_text = _('The website of the organization.'))
+    description = TextField(_('description'), blank = True,
+        help_text = _('Additional information about the organization, that is not covered by the above fields.'))
 
-	class Meta:
-		db_table = 'licenses_organization'
-		ordering = ('name', )
-		verbose_name = _('organization')
-		verbose_name_plural = _('organizations')
+    class Meta:
+        db_table = 'licenses_organization'
+        ordering = ('name', )
+        verbose_name = _('organization')
+        verbose_name_plural = _('organizations')
 
-	def __unicode__(self):
-		return self.name
+    def __unicode__(self):
+        return self.name
 
-	@property
-	def url(self):
-		return self.website
+    @property
+    def url(self):
+        return self.website
 
 
 class License(Model):
-	'''
-		A license.
-	'''
-	name = CharField(_('name'), max_length = 200, unique = True,
-		help_text = _('The full name of the license.'))
-	slug = SlugField(_('slug'), unique = True)
-	organization = ForeignKey(Organization, verbose_name = _('organization'), related_name = 'licenses', blank = True, null = True)
-	abbreviation = CharField(_('abbreviation'), max_length = 50, blank = True,
-		help_text = _('The short name of the license.'))
-	url = URLField(_('url'), verify_exists = True,
-		help_text = _('The URL to the legal text/online representation of the license.'))
-	logo = URLField(_('logo'), verify_exists = True, blank = True,
-		help_text = _('A logo/icon/badge that is clearly associated with the license.'))
-	description = TextField(_('description'), blank = True)
-	is_active = BooleanField(_('active'), default = True,
-		help_text = _('Disable, if license shouldn\'t be available to users any more.'))
+    '''
+        A license.
+    '''
+    name = CharField(_('name'), max_length = 200, unique = True,
+        help_text = _('The full name of the license.'))
+    slug = SlugField(_('slug'), unique = True)
+    organization = ForeignKey(Organization, verbose_name = _('organization'), related_name = 'licenses', blank = True, null = True)
+    abbreviation = CharField(_('abbreviation'), max_length = 50, blank = True,
+        help_text = _('The short name of the license.'))
+    url = URLField(_('url'), verify_exists = True,
+        help_text = _('The URL to the legal text/online representation of the license.'))
+    logo = URLField(_('logo'), verify_exists = True, blank = True,
+        help_text = _('A logo/icon/badge that is clearly associated with the license.'))
+    description = TextField(_('description'), blank = True)
+    is_active = BooleanField(_('active'), default = True,
+        help_text = _('Disable, if license shouldn\'t be available to users any more.'))
 
-	def __unicode__(self):
-		return self.name
+    def __unicode__(self):
+        return self.name
 
-	class Meta:
-		db_table = 'licenses_license'
-		ordering = ('name', )
-		verbose_name = _('license')
-		verbose_name_plural = _('licenses')
+    class Meta:
+        db_table = 'licenses_license'
+        ordering = ('name', )
+        verbose_name = _('license')
+        verbose_name_plural = _('licenses')

licenses/templatetags/licensing.py

 
 
 class GetLicenseNode(template.Node):
-	'''
-		Generic node to get one license, the tag defines the search paramter.
-	'''
+    '''
+        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 %s must be 'as'" % tokens[0])
-			return cls(
-				abbr = tokens[1][1:-1], # TODO: not a safe parser for quotes
-				varname = tokens[3],
-			)
-		else:
-			raise template.TemplateSyntaxError("%r tag requires 3 arguments" % tokens[0])
+    @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 %s must be 'as'" % tokens[0])
+            return cls(
+                abbr = tokens[1][1:-1], # TODO: not a safe parser for quotes
+                varname = tokens[3],
+            )
+        else:
+            raise template.TemplateSyntaxError("%r tag requires 3 arguments" % tokens[0])
 
-	def __init__(self, abbr = None, varname = None):
-		self.varname = varname
-		self.abbr = abbr
+    def __init__(self, abbr = None, varname = None):
+        self.varname = varname
+        self.abbr = abbr
 
-	def render(self, context):
-		try:
-			license = License.objects.filter(abbreviation = self.abbr)[0]
-		except IndexError:
-			license = None
-		context[self.varname] = license
-		return ''
+    def render(self, context):
+        try:
+            license = License.objects.filter(abbreviation = self.abbr)[0]
+        except IndexError:
+            license = None
+        context[self.varname] = license
+        return ''
 
 
 # TODO: add get_license_by_slug, etc
 @register.tag
 def get_license_by_abbr(parser, token):
-	'''
-		Usage: {% get_license_by_abbr "short_name" as varname %}
-	'''
-	return GetLicenseNode.handle_token(parser, token)
+    '''
+        Usage: {% get_license_by_abbr "short_name" as varname %}
+    '''
+    return GetLicenseNode.handle_token(parser, token)
 
 
 # TODO: ?? put html into template?
 @register.filter
 def license_link(license):
-	'''
-		Usage {{ license|license_link }}
-	'''
-	data = {
-		'name': conditional_escape(license.name),
-		'url': conditional_escape(license.url),
-	}
-	return mark_safe('<a rel="license" href="%(url)s">%(name)s</a>' % data)
+    '''
+        Usage {{ license|license_link }}
+    '''
+    data = {
+        'name': conditional_escape(license.name),
+        'url': conditional_escape(license.url),
+    }
+    return mark_safe('<a rel="license" href="%(url)s">%(name)s</a>' % data)
 
 
 @register.filter
 def license_logo(license):
-	'''
-		Usage {{ license|license_logo }}
-	'''
-	data = {
-		'name': conditional_escape(license.name),
-		'url': conditional_escape(license.url),
-		'img': conditional_escape(license.logo),
-	}
-	return mark_safe('<a rel="license" href="%(url)s"><img src="%(img)s" title="%(name)s" alt="%(name)s" /></a>' % data)
+    '''
+        Usage {{ license|license_logo }}
+    '''
+    data = {
+        'name': conditional_escape(license.name),
+        'url': conditional_escape(license.url),
+        'img': conditional_escape(license.logo),
+    }
+    return mark_safe('<a rel="license" href="%(url)s"><img src="%(img)s" title="%(name)s" alt="%(name)s" /></a>' % data)
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.