-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- On this commit, website is not yet fully functional - Add ManualPDFTemplate - PDFFile are now separed from configuration to create them to ManualPDFTemplate - PDFTemplate as common ancestor of Category and ManualPDFTemplate
- Loading branch information
Showing
18 changed files
with
688 additions
and
90 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Generated by Django 5.1.4 on 2024-12-20 18:42 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0012_rename_prerendered_pdf_song_prerendered_and_more"), | ||
("category", "0013_category2"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="song", | ||
name="categories", | ||
field=models.ManyToManyField(to="category.category2", verbose_name="Categories"), | ||
), | ||
] |
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,77 @@ | ||
# Generated by Django 5.1.4 on 2024-12-20 18:29 | ||
|
||
import django.db.models.deletion | ||
from django.db import migrations, models | ||
|
||
|
||
def recreate_categories(apps, schema_editor): | ||
Category = apps.get_model("category", "Category") | ||
NewCategory = apps.get_model("category", "Category2") | ||
ContentType = apps.get_model("contenttypes", "ContentType") | ||
db_alias = schema_editor.connection.alias | ||
|
||
for category in Category.objects.using(db_alias).all(): | ||
new_category = NewCategory() | ||
new_category.polymorphic_ctype_id = ContentType.objects.get_for_model(Category).pk | ||
for field in [ | ||
"pk", | ||
"filename", | ||
"public", | ||
"locale", | ||
"title", | ||
"show_date", | ||
"image", | ||
"margin", | ||
"link", | ||
"generate_pdf", | ||
"tenant_id", | ||
"slug", | ||
"name", | ||
]: | ||
setattr(new_category, field, getattr(category, field)) | ||
new_category.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("category", "0012_alter_category_link"), | ||
("pdf", "0026_pdftemplate_pdffile_alter_pdfrequest_options_and_more"), | ||
("tenants", "0005_link_tenant_links"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Category2", | ||
fields=[ | ||
( | ||
"pdftemplate_ptr", | ||
models.OneToOneField( | ||
auto_created=True, | ||
on_delete=django.db.models.deletion.CASCADE, | ||
parent_link=True, | ||
primary_key=True, | ||
serialize=False, | ||
to="pdf.pdftemplate", | ||
), | ||
), | ||
("name", models.CharField(max_length=100, verbose_name="Name")), | ||
("slug", models.SlugField(max_length=25, verbose_name="URL pattern")), | ||
( | ||
"generate_pdf", | ||
models.BooleanField( | ||
help_text="Should the PDF file be automatically generated when a song changes?", | ||
verbose_name="PDF generation", | ||
), | ||
), | ||
("tenant", models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="tenants.tenant")), | ||
], | ||
options={ | ||
"verbose_name": "Category", | ||
"verbose_name_plural": "Categories", | ||
"unique_together": {("tenant", "name"), ("tenant", "slug")}, | ||
}, | ||
bases=("pdf.pdftemplate",), | ||
), | ||
migrations.RunPython(recreate_categories), | ||
] |
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,17 @@ | ||
# Generated by Django 5.1.4 on 2024-12-20 18:51 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0013_alter_song_categories"), | ||
("category", "0013_category2"), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name="Category", | ||
), | ||
] |
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,20 @@ | ||
# Generated by Django 5.1.4 on 2024-12-20 18:51 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("backend", "0013_alter_song_categories"), | ||
("category", "0014_delete_category"), | ||
("pdf", "0026_pdftemplate_pdffile_alter_pdfrequest_options_and_more"), | ||
("tenants", "0005_link_tenant_links"), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameModel( | ||
old_name="Category2", | ||
new_name="Category", | ||
), | ||
] |
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,19 @@ | ||
# File handling in Song Book | ||
|
||
## Models | ||
|
||
### PDFTemplate | ||
* Represents set of configuration options that are used for generating a PDFFile | ||
* No way of recreating exactly the same file, PDFTemplates can change and every regeneration will be based on the new configuration | ||
|
||
#### ManualPDFTemplate | ||
#### Category | ||
* Category is a subclass of PDFTemplate and provides songs | ||
|
||
### PDFFile | ||
* Represents single file that is either generated or scheduled for generation | ||
|
||
### NumberedSong | ||
* Song + fixed song number, used in PDFTemplate to change order of songs in PDF | ||
|
||
## Workflow |
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
Oops, something went wrong.