Compare commits

...

4 Commits

Author SHA1 Message Date
4d964291b2 Fixed poetry deps 2025-08-29 12:51:01 +10:00
ee5305ba6c Merge branch 'master' of gitea.tfconsulting.com.au:projects/polyphonic 2025-08-29 11:39:58 +10:00
Tris Forster
02858a76c0 Cleanup 2024-08-05 15:49:39 +10:00
Tris Forster
1bcec919cf PEP Cleanup 2024-08-05 12:53:58 +10:00
3 changed files with 25 additions and 21 deletions

View File

@ -55,4 +55,4 @@
{% block scripts %} {% block scripts %}
{% endblock %} {% endblock %}
</body> </body>
</html> </html>

View File

@ -43,13 +43,13 @@ class Orchestration(models.Model):
def as_list(self): def as_list(self):
tags = [ t.strip() for t in self.instruments.split(' ') ] tags = [ t.strip() for t in self.instruments.split(' ') ]
return [ (t, MusicTag.from_tag(t)) for t in tags if t ] return [ (t, MusicTag.from_tag(t)) for t in tags if t ]
def tag_order(self): def tag_order(self):
tags = [ t.strip() for t in self.instruments.split(' ') if t ] tags = [ t.strip() for t in self.instruments.split(' ') if t ]
order = {'score': 0} order = {'score': 0}
for i, t in enumerate(tags): for i, t in enumerate(tags):
order.setdefault(t.strip('-0123456789'), i*2+1) order.setdefault(t.strip('-0123456789'), i*2+1)
return order return order
def sorter(self): def sorter(self):
@ -78,14 +78,13 @@ class ProjectItem(models.Model):
approved_by = models.ForeignKey('auth.User', on_delete=models.CASCADE) approved_by = models.ForeignKey('auth.User', on_delete=models.CASCADE)
order = models.SmallIntegerField(default=0) order = models.SmallIntegerField(default=0)
section = models.CharField(max_length=100, blank=True) section = models.CharField(max_length=100, blank=True)
class Meta: class Meta:
ordering = ['order', 'work'] ordering = ['order', 'work']
def __str__(self): def __str__(self):
return f"<{self.project_id}:{slugify(self.work.name)}>" return f"<{self.project_id}:{slugify(self.work.name)}>"
class Collection(models.Model): class Collection(models.Model):
""" """
A logical collection of works, typically owned by an organisation or person (physical or virtual) A logical collection of works, typically owned by an organisation or person (physical or virtual)
@ -94,13 +93,13 @@ class Collection(models.Model):
help_text="Name of the collection") help_text="Name of the collection")
prefix = models.CharField(max_length=255, default="default", prefix = models.CharField(max_length=255, default="default",
help_text="Folder to store works in") help_text="Folder to store works in")
administrators = models.ManyToManyField('auth.User', related_name="collections", administrators = models.ManyToManyField('auth.User', related_name="collections",
help_text="Administrators for this collection") help_text="Administrators for this collection")
location = models.CharField(max_length=100, location = models.CharField(max_length=100,
help_text="Physical location (institution, town...)", blank=True) help_text="Physical location (institution, town...)", blank=True)
storage = models.ForeignKey('byostorage.UserStorage', on_delete=models.CASCADE, null=True, blank=True, storage = models.ForeignKey('byostorage.UserStorage', on_delete=models.CASCADE, null=True, blank=True,
help_text="User storage for documents") help_text="User storage for documents")
notes = models.TextField(blank=True, notes = models.TextField(blank=True,
help_text="Publicly visible notes about collection and loans policy (markdown format)") help_text="Publicly visible notes about collection and loans policy (markdown format)")
settings = models.JSONField(default=dict, blank=True, settings = models.JSONField(default=dict, blank=True,
help_text="Storage specific settings") help_text="Storage specific settings")
@ -117,8 +116,8 @@ class Collection(models.Model):
@property @property
def genres(self): def genres(self):
return self.meta('genre') return self.meta('genre')
def has_administrator(self, user): def has_administrator(self, user):
if not user.is_authenticated: if not user.is_authenticated:
return False return False
@ -131,7 +130,7 @@ class Collection(models.Model):
def auth(self): def auth(self):
return sign_data(f'{self.pk}-{self.nonce}', 12) return sign_data(f'{self.pk}-{self.nonce}', 12)
def __str__(self): def __str__(self):
return self.name return self.name
@ -175,7 +174,7 @@ class Work(models.Model):
(LICENCE_PERUSAL, 'Perusal Licence'), (LICENCE_PERUSAL, 'Perusal Licence'),
(LICENCE_NONE, 'Internal use only'), (LICENCE_NONE, 'Internal use only'),
) )
name = models.CharField(max_length=255, help_text="Original name of the work") name = models.CharField(max_length=255, help_text="Original name of the work")
edition = models.CharField(max_length=255, blank=True, edition = models.CharField(max_length=255, blank=True,
help_text="Edition details to distinguish multiple versions") help_text="Edition details to distinguish multiple versions")
@ -192,7 +191,7 @@ class Work(models.Model):
code = models.CharField(max_length=100, blank=True, help_text="Collection specific code or number. Will be auto-generated if not supplied") code = models.CharField(max_length=100, blank=True, help_text="Collection specific code or number. Will be auto-generated if not supplied")
licence = models.PositiveSmallIntegerField(choices=LICENCE_TYPES, default=6, help_text="Copyright status") licence = models.PositiveSmallIntegerField(choices=LICENCE_TYPES, default=6, help_text="Copyright status")
max_projects = models.IntegerField(default=1, help_text="How many active projects can this work be attached to") max_projects = models.IntegerField(default=1, help_text="How many active projects can this work be attached to")
# Extra info # Extra info
running_time = models.DurationField(null=True, blank=True, help_text="Running time in mm:ss format") running_time = models.DurationField(null=True, blank=True, help_text="Running time in mm:ss format")
notes = models.TextField(blank=True) notes = models.TextField(blank=True)
@ -220,7 +219,7 @@ class Work(models.Model):
#return [ s[1] for s in sections ] #return [ s[1] for s in sections ]
sections = list(dict(sections).items()) # primitive unique() sections = list(dict(sections).items()) # primitive unique()
return sections return sections
def pdfs(self): def pdfs(self):
return self.docs.filter(doctype=Document.DOCTYPE_PDF) return self.docs.filter(doctype=Document.DOCTYPE_PDF)
@ -305,7 +304,7 @@ class WorkMeta(models.Model):
('style', 'Style'), ('style', 'Style'),
('orchestration', 'Orchestration'), ('orchestration', 'Orchestration'),
) )
work = models.ForeignKey(Work, on_delete=models.CASCADE, related_name='meta_info') work = models.ForeignKey(Work, on_delete=models.CASCADE, related_name='meta_info')
name = models.SlugField(max_length=20, choices=META_CHOICES) name = models.SlugField(max_length=20, choices=META_CHOICES)
value = models.CharField(max_length=255) value = models.CharField(max_length=255)
@ -349,7 +348,7 @@ class Document(models.Model):
def delete(self, *args, **kwargs): def delete(self, *args, **kwargs):
self.upload.delete(save=False) self.upload.delete(save=False)
return super().delete(*args, **kwargs) return super().delete(*args, **kwargs)
def filename(self): def filename(self):
return os.path.basename(self.upload.name) return os.path.basename(self.upload.name)
@ -360,7 +359,7 @@ class Section(models.Model):
""" """
Section is a tagged portion of a Document Section is a tagged portion of a Document
""" """
PAGE_AUTO = 0 PAGE_AUTO = 0
PAGE_LEFT = 1 PAGE_LEFT = 1
PAGE_RIGHT = 2 PAGE_RIGHT = 2
@ -397,7 +396,7 @@ class Section(models.Model):
def filename(self): def filename(self):
return slugify(f'{self.doc.work.name} - {self.name}').title() + '.pdf' return slugify(f'{self.doc.work.name} - {self.name}').title() + '.pdf'
@property @property
def pagerange(self): def pagerange(self):
if self.start: if self.start:
if self.end: if self.end:
@ -407,3 +406,4 @@ class Section(models.Model):
def __str__(self): def __str__(self):
return self.name return self.name

View File

@ -12,14 +12,18 @@ dependencies = [
"django-crispy-forms", "django-crispy-forms",
"django-markdown2", "django-markdown2",
"django-rest-framework", "django-rest-framework",
"crispy-bulma (>=0.12.0,<0.13.0)" "crispy-bulma (>=0.12.0,<0.13.0)",
"django-byostorage @ git+https://gitea.tfconsulting.com.au/tris/django-byostorage.git@9903bb00888f20dfd2d39754e5ee22eeb5f36298",
"requests (>=2.32.5,<3.0.0)",
"django-storages (>=1.14.6,<2.0.0)",
"boto3 (>=1.40.20,<2.0.0)"
] ]
[tool.poetry] [tool.poetry]
packages = [{include = "*", from="app"}] packages = [{include = "*", from="app"}]
[tool.poetry.group.dev.dependencies] [tool.poetry.group.dev.dependencies]
django-debug-toolbar = "3.8.1" django-debug-toolbar = "5.2"
[build-system] [build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"] requires = ["poetry-core>=2.0.0,<3.0.0"]