-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Content License drop down to select license of book (#1285)
* Added Content License snippet and drop down to select license of book * Add missing migrations * Fixed missed conflict * Fixed migration merge issue * Management command to add license where missing on live books * Removed License snippet and used constants instead * Added default for dropdown * Altered default and choices
- Loading branch information
1 parent
527eeb2
commit ab95750
Showing
12 changed files
with
167 additions
and
4 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,18 @@ | ||
from django.core.management.base import BaseCommand | ||
|
||
from snippets.models import ContentLicense | ||
from books.models import Book | ||
|
||
class Command(BaseCommand): | ||
help="add CC license to live books that do not have one" | ||
|
||
def handle(self, *args, **options): | ||
nc_sa_books = ['Cálculo volumen 1', 'Cálculo volumen 2', 'Cálculo volumen 3'] | ||
books = Book.objects.filter(license_name=None, book_state='live') | ||
for book in books: | ||
if book.book_title in nc_sa_books: | ||
book.license_name = 'Creative Commons Attribution-NonCommercial-ShareAlike License' | ||
else: | ||
book.license_name = 'Creative Commons Attribution License' | ||
book.save() | ||
print('Updated license for ' + str(book.book_title)) |
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,18 @@ | ||
# Generated by Django 3.2.5 on 2022-05-09 20:10 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('books', '0133_bookcategories_bookcategory'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='book', | ||
name='license_name', | ||
field=models.CharField(blank=True, choices=[('Creative Commons Attribution License', 'Creative Commons Attribution License'), ('Creative Commons Attribution-NonCommercial-ShareAlike License', 'Creative Commons Attribution-NonCommercial-ShareAlike License')], help_text='Name of the license.', max_length=255, null=True), | ||
), | ||
] |
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,18 @@ | ||
# Generated by Django 3.2.5 on 2022-05-11 12:58 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('books', '0134_alter_book_license_name'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='book', | ||
name='license_name', | ||
field=models.CharField(blank=True, choices=[('Creative Commons Attribution License', 'Creative Commons Attribution License'), ('Creative Commons Attribution-NonCommercial-ShareAlike License', 'Creative Commons Attribution-NonCommercial-ShareAlike License')], default='Creative Commons Attribution License', help_text='Name of the license.', max_length=255, null=True), | ||
), | ||
] |
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,32 @@ | ||
# Generated by Django 3.2.5 on 2022-05-09 15:39 | ||
|
||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wagtailcore', '0066_collection_management_permissions'), | ||
('snippets', '0019_givebanner'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ContentLicense', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('translation_key', models.UUIDField(default=uuid.uuid4, editable=False)), | ||
('license_code', models.CharField(blank=True, max_length=255, null=True)), | ||
('version', models.CharField(blank=True, max_length=255, null=True)), | ||
('license_name', models.CharField(blank=True, max_length=255, null=True)), | ||
('license_url', models.URLField(blank=True, null=True)), | ||
('locale', models.ForeignKey(editable=False, on_delete=django.db.models.deletion.PROTECT, related_name='+', to='wagtailcore.locale')), | ||
], | ||
options={ | ||
'abstract': False, | ||
'unique_together': {('translation_key', 'locale')}, | ||
}, | ||
), | ||
] |
14 changes: 14 additions & 0 deletions
14
snippets/migrations/0022_merge_0020_contentlicense_0021_blogcollection.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,14 @@ | ||
# Generated by Django 3.2.5 on 2022-05-10 15:37 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('snippets', '0020_contentlicense'), | ||
('snippets', '0021_blogcollection'), | ||
] | ||
|
||
operations = [ | ||
] |
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 @@ | ||
# Generated by Django 3.2.5 on 2022-05-10 21:12 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('snippets', '0022_merge_0020_contentlicense_0021_blogcollection'), | ||
] | ||
|
||
operations = [ | ||
migrations.DeleteModel( | ||
name='ContentLicense', | ||
), | ||
] |
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 |
---|---|---|
|
@@ -314,4 +314,5 @@ def __str__(self): | |
return self.name | ||
|
||
|
||
register_snippet(BlogCollection) | ||
register_snippet(BlogCollection) | ||
|
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 |
---|---|---|
|
@@ -62,3 +62,4 @@ class Meta: | |
fields = ('name', | ||
'description', | ||
'collection_image') | ||
|
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