Skip to content

Instantly share code, notes, and snippets.

@agaerig
Created February 15, 2013 16:37
Show Gist options
  • Select an option

  • Save agaerig/4961575 to your computer and use it in GitHub Desktop.

Select an option

Save agaerig/4961575 to your computer and use it in GitHub Desktop.
def get_apps():
types = ContentType.objects.all()
allowed_types = []
for ct in types:
m = ct.model_class()
if m.__module__ in ALLOWED_APPS:
choice = '%s.%s' % (m.__module__, m.__name__)
allowed_types.append(choice)
return allowed_types
APPS = ('festivalappearance', 'festivaledition')
def edit_contents(instance):
return ('<a href="%s">Edit Contents</a>' %
reverse('scheduler-edit-bucket-contents', args=(instance.id, )))
edit_contents.short_description = 'Edit'
edit_contents.allow_tags = True
class BucketForm(forms.ModelForm):
allowed_types = forms.MultipleChoiceField(widget=CheckboxSelectMultiple,
choices=APPS)
class BucketAdmin(admin.ModelAdmin):
list_display = ('name', edit_contents,)
ordering = ('name', )
form = BucketForm
def get_readonly_fields(self, request, instance=None):
if not request.user.is_superuser:
return ('key', 'limit')
return []
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment