-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1548 from dchiller/i1541-return-segment-to-source…
…-level Add `Project` model for chants & return segment to a source-level object
- Loading branch information
Showing
19 changed files
with
284 additions
and
188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from django.contrib import admin | ||
|
||
from main_app.admin.base_admin import BaseModelAdmin | ||
from main_app.models import Project | ||
|
||
|
||
@admin.register(Project) | ||
class ProjectAdmin(BaseModelAdmin): | ||
search_fields = ("name",) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 0 additions & 44 deletions
44
django/cantusdb_project/main_app/management/commands/assign_chants_to_segments.py
This file was deleted.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
django/cantusdb_project/main_app/management/commands/assign_sequences_to_bower_project.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" | ||
This command is meant to be used one time toward solving issue | ||
1542, assigning chants and sequences, where necessary, to their appropriate | ||
"project". | ||
This command assigns sequences to the Bower project. Chants | ||
(in non-Bower sources) currently have | ||
project. | ||
Note: This command can only be run *after* the Bower project has been created | ||
in the database through the Admin interface. | ||
Note: This command is designed to be run once in order to complete the necessary | ||
data migrations with the introduction of the Project model. It is not intended | ||
for multiple runs. | ||
""" | ||
|
||
from django.core.management.base import BaseCommand | ||
from main_app.models import Project, Sequence | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Assigns all sequences to the Bower project." | ||
|
||
def handle(self, *args, **options): | ||
sequences = Sequence.objects.all() | ||
bower_project = Project.objects.get(name="Clavis Sequentiarum") | ||
if not bower_project: | ||
self.stdout.write( | ||
self.style.ERROR( | ||
"The Bower project does not exist. Please create it in the Admin interface." | ||
) | ||
) | ||
return | ||
sequences.update(project=bower_project) | ||
self.stdout.write( | ||
self.style.SUCCESS( | ||
f"All sequences have been assigned to the {bower_project} project." | ||
) | ||
) |
96 changes: 96 additions & 0 deletions
96
...main_app/migrations/0020_remove_chant_segment_remove_sequence_segment_project_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Generated by Django 4.2.11 on 2024-06-18 13:04 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("main_app", "0019_remove_source_rism_siglum_delete_rismsiglum"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="chant", | ||
name="segment", | ||
), | ||
migrations.RemoveField( | ||
model_name="sequence", | ||
name="segment", | ||
), | ||
migrations.CreateModel( | ||
name="Project", | ||
fields=[ | ||
( | ||
"id", | ||
models.AutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"date_created", | ||
models.DateTimeField( | ||
auto_now_add=True, help_text="The date this entry was created" | ||
), | ||
), | ||
( | ||
"date_updated", | ||
models.DateTimeField( | ||
auto_now=True, help_text="The date this entry was updated" | ||
), | ||
), | ||
("name", models.CharField(max_length=63)), | ||
( | ||
"created_by", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="%(class)s_created_by_user", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"last_updated_by", | ||
models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
related_name="%(class)s_last_updated_by_user", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
], | ||
options={ | ||
"abstract": False, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name="chant", | ||
name="project", | ||
field=models.ForeignKey( | ||
blank=True, | ||
help_text="The project this chant belongs to. If left blank,this chant is considered part of the Cantus (default) project.", | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to="main_app.project", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="sequence", | ||
name="project", | ||
field=models.ForeignKey( | ||
blank=True, | ||
help_text="The project this chant belongs to. If left blank,this chant is considered part of the Cantus (default) project.", | ||
null=True, | ||
on_delete=django.db.models.deletion.PROTECT, | ||
to="main_app.project", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from main_app.models import BaseModel | ||
from django.db import models | ||
|
||
|
||
class Project(BaseModel): | ||
""" | ||
Chants can be tagged with the Project if their inventories are collected | ||
as part of a particular project or initiative. Tagging a chant with a | ||
project allows for the collection of project-specific chant data during | ||
the inventory process and enables filtering by project during search. | ||
""" | ||
|
||
name = models.CharField(max_length=63) | ||
|
||
def __str__(self): | ||
return f"{self.name} ({self.id})" |
Oops, something went wrong.