Skip to content

Commit

Permalink
Bumping up everything, ISWC from ISW fix
Browse files Browse the repository at this point in the history
  • Loading branch information
matijakolaric committed Jul 9, 2024
1 parent 06eef59 commit c315d97
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 36 deletions.
40 changes: 28 additions & 12 deletions music_publisher/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2228,18 +2228,34 @@ def process(self, request, ack_import, file_content, import_iswcs=False):
level=messages.ERROR,
)
else:
work.iswc = iswc
work.last_change = now()
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,
work.id,
str(work),
CHANGE,
s,
)
work.save()
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)
)
self.message_user(
request,
"Duplicate works found for ISWC {}!".format(iswc),
level=messages.ERROR,
)
else:
work.iswc = iswc
work.last_change = now()
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,
work.id,
str(work),
CHANGE,
s,
)
work.save()
if unknown_work_ids:
messages.add_message(
request,
Expand Down
4 changes: 2 additions & 2 deletions music_publisher/tests/CW220001052_DMP.V21
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ GRT000010000005000000007
GRHISW0000202.100020180607
ISW0000000000000000MUSIC PUB CARTOONS MK000001 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N
ISW0000000100000000MUSIC PUB CARTOONS MK000001 T123456789300000000 UNC000000Y MOD UNSUNS N00000000000 N
ISW0000000200000000MUSIC PUB CARTOONS MK000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N
ISW0000000200000000MUSIC PUB CARTOONS MK000002 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N
GRT000020000003000000003
TRL000010000008000000014
TRL000020000008000000014
2 changes: 1 addition & 1 deletion music_publisher/tests/CW220002DMP_0000_V3-0-0.SUB
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDRPBDMP TEST PUBLISHER 2020012214074420200122 3.0000 CW230002DMP_0000_V3-0-0.SUB
HDRPBDMP TEST PUBLISHER 2020012214074420200122 3.0000 CW240002DMP_0000_V3-0-0.SUB
GRHWRK0000103.000000000000
WRK0000000000000000MUSIC PUB CARTOONS DMP000001 T123456789400000000 UNC000000Y MOD UNSUNSN00000000000 N
SPU000000000000000101P000001 TEST PUBLISHER NE 00000000009000000020
Expand Down
2 changes: 1 addition & 1 deletion music_publisher/tests/CW220003DMP_0000_V3-0-0.ISR
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
HDRPBDMP TEST PUBLISHER 2020012214074420200122 3.0000 CW230003DMP_0000_V3-0-0.ISR
HDRPBDMP TEST PUBLISHER 2020012214074420200122 3.0000 CW240003DMP_0000_V3-0-0.ISR
GRHISR0000103.000000000000
ISR0000000000000000MUSIC PUB CARTOONS T1234567894U
WRI0000000000000001W000001 00000000199KOLARIC MATIJA
Expand Down
21 changes: 13 additions & 8 deletions music_publisher/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -1202,6 +1202,10 @@ def test_ack_import_and_work_filters(self):
"(SMITH): T3221234234 (old) vs T1234567893 (new).",
music_publisher.models.ACKImport.objects.first().report,
)
self.assertIn(
"One ISWC can not be used for two works: T3221234234 ",
music_publisher.models.ACKImport.objects.first().report,
)

"""This file has also ISWC codes."""
mock = StringIO()
Expand Down Expand Up @@ -2235,7 +2239,7 @@ def test_work(self):
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230001DMP_000.V21")
self.assertEqual(cwr.filename, "CW240001DMP_000.V21")
self.assertEqual(cwr.cwr.encode()[0:64], TEST_CONTENT[0:64])
self.assertEqual(cwr.cwr.encode()[86:], TEST_CONTENT[86:])

Expand All @@ -2245,7 +2249,7 @@ def test_work(self):
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230002DMP_0000_V3-0-0.SUB")
self.assertEqual(cwr.filename, "CW240002DMP_0000_V3-0-0.SUB")
self.assertEqual(cwr.cwr.encode()[0:65], TEST_CONTENT[0:65])
self.assertEqual(cwr.cwr.encode()[167:], TEST_CONTENT[167:])
# should just return when once created
Expand All @@ -2259,7 +2263,7 @@ def test_work(self):
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230003DMP_0000_V3-0-0.ISR")
self.assertEqual(cwr.filename, "CW240003DMP_0000_V3-0-0.ISR")
self.assertEqual(cwr.cwr.encode()[0:65], TEST_CONTENT[0:65])
self.assertEqual(cwr.cwr.encode()[167:], TEST_CONTENT[167:])

Expand All @@ -2276,21 +2280,21 @@ def test_work(self):
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230004DMP_000.V22")
self.assertEqual(cwr.filename, "CW240004DMP_000.V22")

# test CWR 2.2 REV
cwr = music_publisher.models.CWRExport(nwr_rev="RE2")
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230005DMP_000.V22")
self.assertEqual(cwr.filename, "CW240005DMP_000.V22")

# test CWR 3.1 WRK
cwr = music_publisher.models.CWRExport(nwr_rev="WR1")
cwr.save()
cwr.works.add(work)
cwr.create_cwr()
self.assertEqual(cwr.filename, "CW230006DMP_0000_V3-1-0.SUB")
self.assertEqual(cwr.filename, "CW240006DMP_0000_V3-1-0.SUB")


class OtherFunctionalTest(SimpleTestCase):
Expand Down Expand Up @@ -2386,8 +2390,9 @@ def test_serializers(self):
ISW0000000000000000MUSIC PUB CARTOONS MK000001 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N
ISW0000000100000000MUSIC PUB CARTOONS MK000001 T123456789300000000 UNC000000Y MOD UNSUNS N00000000000 N
ISW0000000200000000MUSIC PUB CARTOONS XX000001 T123456789400000000 UNC000000Y MOD UNSUNS N00000000000 N
GRT000020000003000000003
TRL000010000008000000014"""
ISW0000000400000000MUSIC PUB CARTOONS MK000003 T322123423400000000 UNC000000Y MOD UNSUNS N00000000000 N
GRT000020000004000000004
TRL000010000008000000015"""


ACK_CONTENT_21_EXT = """HDRSO000000052PRS for Music 01.102018060715153220180607
Expand Down
22 changes: 11 additions & 11 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
Django>=4.1.7,<4.2
boto3==1.26.103
dj_database_url==1.3.0
django-cleanup==7.0.0
djangorestframework==3.14.0
django-storages==1.13.2
Django>=4.2.13,<5.0
boto3==1.34.141
dj_database_url==2.2.0
django-cleanup==8.1.0
django-storages==1.14.4
djangorestframework==3.15.2
music-metadata-territories==22.6
Markdown==3.4.3
Pillow==9.4.0
psycopg2-binary==2.9.5
waitress==2.1.2
whitenoise==6.4.0
Markdown==3.6
Pillow==10.4.0
psycopg2-binary==2.9.9
waitress==3.0.0
whitenoise==6.7

2 changes: 1 addition & 1 deletion runtime.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
python-3.11.2
python-3.12.4

0 comments on commit c315d97

Please sign in to comment.