Automatic challenge creator user
This commit is contained in:
parent
86e338f981
commit
23e122dab6
@ -2,6 +2,15 @@ from django.contrib import admin
|
||||
from kspace.models import *
|
||||
|
||||
|
||||
class ChallengeAdmin(admin.ModelAdmin):
|
||||
list_display = ('name', 'description', 'creator',)
|
||||
|
||||
def save_model(self, request, obj, form, change):
|
||||
if getattr(obj, 'creator', None) is None:
|
||||
obj.creator = request.user
|
||||
obj.save()
|
||||
|
||||
|
||||
class InventoryItemAdmin(admin.ModelAdmin):
|
||||
list_display = ('item_name', 'serial_nr', 'usable', 'owner', 'creator',)
|
||||
|
||||
@ -17,7 +26,8 @@ class InventoryItemLocationAdmin(admin.ModelAdmin):
|
||||
class Media:
|
||||
js = ('/static/admin/js/hide_attribute.js',)
|
||||
|
||||
admin.site.register(Challenge)
|
||||
|
||||
admin.site.register(Challenge, ChallengeAdmin)
|
||||
admin.site.register(ChallengeTag)
|
||||
admin.site.register(UserChallenge)
|
||||
admin.site.register(Profile)
|
||||
|
@ -44,7 +44,7 @@ class ChallengeTag(models.Model):
|
||||
|
||||
class Challenge(models.Model):
|
||||
id = models.AutoField(primary_key=True)
|
||||
creator = models.ForeignKey(User)
|
||||
creator = models.ForeignKey(User, blank=True, null=True, editable=False)
|
||||
name = models.CharField(max_length=256)
|
||||
description = models.TextField(blank=True)
|
||||
tags = models.ManyToManyField(ChallengeTag, blank=True)
|
||||
|
Reference in New Issue
Block a user