Skip to content

Commit

Permalink
Blacked
Browse files Browse the repository at this point in the history
  • Loading branch information
matijakolaric committed Jul 9, 2024
1 parent c315d97 commit 2818ddd
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
25 changes: 14 additions & 11 deletions music_publisher/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
All views are here, except for :mod:`.royalty_calculation`.
"""

import re
import zipfile
from csv import DictWriter
Expand Down Expand Up @@ -1474,9 +1475,9 @@ def write(self, value):
for aff in w.get("affiliations", []):
code = aff["affiliation_type"]["code"]
cmo = aff["organization"]
row[
"Writer {} {}O".format(i + 1, code)
] = "{} - {}".format(cmo["code"], cmo["name"])
row["Writer {} {}O".format(i + 1, code)] = (
"{} - {}".format(cmo["code"], cmo["name"])
)
ops = wiw.get("original_publishers")

row["Writer {} Manuscript Share".format(i + 1)] = Decimal(
Expand Down Expand Up @@ -2231,16 +2232,16 @@ def process(self, request, ack_import, file_content, import_iswcs=False):
duplicate = Work.objects.exclude(id=work.id)
duplicate = duplicate.filter(iswc__iexact=iswc).first()
if duplicate:
report += (
"One ISWC can not be used for two works: "
+ "{} {} {}.<br/>\n".format(iswc, duplicate, work)
+ "This usually happens if one work is entered "
"twice. "
+ "ISWC not imported for {}.<br/>\n".format(work)
report += "One ISWC can not be used for two works: " + "{} {} {}.<br/>\n".format(
iswc, duplicate, work
) + "This usually happens if one work is entered " "twice. " + "ISWC not imported for {}.<br/>\n".format(
work
)
self.message_user(
request,
"Duplicate works found for ISWC {}!".format(iswc),
"Duplicate works found for ISWC {}!".format(
iswc
),
level=messages.ERROR,
)
else:
Expand All @@ -2249,7 +2250,9 @@ def process(self, request, ack_import, file_content, import_iswcs=False):
s = f"ISWC imported from ISW file: {ack_import_link}."
LogEntry.objects.log_action(
request.user.id,
admin.options.get_content_type_for_model(work).id,
admin.options.get_content_type_for_model(
work
).id,
work.id,
str(work),
CHANGE,
Expand Down
34 changes: 19 additions & 15 deletions music_publisher/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,15 +775,17 @@ def get_dict(self, with_recordings=True):
"code": self.work_id,
"work_title": self.title,
"last_change": self.last_change,
"version_type": {
"code": "MOD",
"name": "Modified Version of a musical work",
}
if self.original_title
else {
"code": "ORI",
"name": "Original Work",
},
"version_type": (
{
"code": "MOD",
"name": "Modified Version of a musical work",
}
if self.original_title
else {
"code": "ORI",
"name": "Original Work",
}
),
"iswc": self.iswc,
"other_titles": [
at.get_dict() for at in self.alternatetitle_set.all()
Expand Down Expand Up @@ -1026,9 +1028,9 @@ def clean(self):
if self.saan:
d["saan"] = "Must be empty if writer is not controlled."
if self.publisher_fee:
d[
"publisher_fee"
] = "Must be empty if writer is not controlled."
d["publisher_fee"] = (
"Must be empty if writer is not controlled."
)
if d:
raise ValidationError(d)

Expand Down Expand Up @@ -1242,9 +1244,11 @@ def title(self):
return (
self.complete_version_title
if self.version_title
else self.complete_recording_title
if self.recording_title
else self.work.title
else (
self.complete_recording_title
if self.recording_title
else self.work.title
)
)

@property
Expand Down

0 comments on commit 2818ddd

Please sign in to comment.