mirror of
https://gitlab.crans.org/mediatek/med.git
synced 2025-07-07 13:04:01 +02:00
Add button to generate a side identifier
This commit is contained in:
@ -40,7 +40,7 @@ def generate_side_identifier(title, authors, subtitle=None):
|
||||
authors = authors.copy()
|
||||
|
||||
def sort(author):
|
||||
return str(-author.note) + author.name.split(" ")[-1] + ".{:05d}".format(author.pk)
|
||||
return "{:042d}".format(-author.note) + author.name.split(" ")[-1] + ".{:042d}".format(author.pk)
|
||||
|
||||
authors.sort(key=sort)
|
||||
primary_author = authors[0]
|
||||
@ -76,6 +76,15 @@ class MediaAdminForm(ModelForm):
|
||||
if isbn_field:
|
||||
isbn_field.widget.template_name = "media/isbn_button.html"
|
||||
isbn_field.widget.attrs.update({'autofocus': 'autofocus'})
|
||||
side_identifier_field = self.fields.get('side_identifier')
|
||||
if side_identifier_field and self.instance and self.instance.pk:
|
||||
instance = self.instance
|
||||
title, authors, subtitle = instance.title, instance.authors.all(), None
|
||||
if hasattr(instance, "subtitle"):
|
||||
subtitle = instance.subtitle
|
||||
side_identifier_field.widget.attrs.update(
|
||||
{'data-generated-side-identifier': generate_side_identifier(title, authors, subtitle)})
|
||||
side_identifier_field.widget.template_name = "media/generate_side_identifier.html"
|
||||
|
||||
def download_data_bedeteque(self, isbn):
|
||||
"""
|
||||
|
Reference in New Issue
Block a user