Merge pull request #232 from Gluejar/acq_admin
add Acq to admin system [#59972686] -> Se test ok; pass to Jenkinspull/1/head
commit
5a7a2dd27a
6
admin.py
6
admin.py
|
@ -83,6 +83,11 @@ class RightsHolderAdmin(ModelAdmin):
|
|||
date_hierarchy = 'created'
|
||||
form = RightsHolderAdminForm
|
||||
|
||||
class AcqAdmin(ModelAdmin):
|
||||
fields = ("expires", "refreshes", )
|
||||
search_fields = ['user__username']
|
||||
date_hierarchy = 'created'
|
||||
|
||||
class PremiumAdmin(ModelAdmin):
|
||||
list_display = ('campaign', 'amount', 'description')
|
||||
date_hierarchy = 'created'
|
||||
|
@ -217,6 +222,7 @@ admin_site.register(Library, LibraryAdmin)
|
|||
admin_site.register(Block, BlockAdmin)
|
||||
admin_site.register(CardPattern, CardPatternAdmin)
|
||||
admin_site.register(EmailPattern, EmailPatternAdmin)
|
||||
admin_site.register(models.Acq, AcqAdmin)
|
||||
admin_site.register(models.Work, WorkAdmin)
|
||||
admin_site.register(models.Claim, ClaimAdmin)
|
||||
admin_site.register(models.RightsHolder, RightsHolderAdmin)
|
||||
|
|
|
@ -277,6 +277,7 @@ class Acq(models.Model):
|
|||
created = models.DateTimeField(auto_now_add=True)
|
||||
expires = models.DateTimeField(null=True)
|
||||
refreshes = models.DateTimeField(auto_now_add=True, default=now())
|
||||
refreshes.editable=True
|
||||
work = models.ForeignKey("Work", related_name='acqs', null=False)
|
||||
user = models.ForeignKey(User, related_name='acqs')
|
||||
license = models.PositiveSmallIntegerField(null = False, default = INDIVIDUAL,
|
||||
|
@ -287,6 +288,12 @@ class Acq(models.Model):
|
|||
# when the acq is a loan, this points at the library's acq it's derived from
|
||||
lib_acq = models.ForeignKey("self", related_name="loans", null=True)
|
||||
|
||||
def __unicode__(self):
|
||||
if self.lib_acq:
|
||||
return "%s, %s: %s for %s" % (self.work, self.get_license_display(), self.lib_acq.user, self.user)
|
||||
else:
|
||||
return "%s, %s for %s" % (self.work, self.get_license_display(), self.user,)
|
||||
|
||||
@property
|
||||
def expired(self):
|
||||
if self.expires is None:
|
||||
|
|
Loading…
Reference in New Issue