diff --git a/comics/migrations/0008_rename_roles_to_credits.py b/comics/migrations/0008_rename_roles_to_credits.py new file mode 100644 index 0000000..a210213 --- /dev/null +++ b/comics/migrations/0008_rename_roles_to_credits.py @@ -0,0 +1,21 @@ +# Generated by Django 2.0.1 on 2018-01-20 21:52 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('comics', '0007_remove_roles_roles'), + ] + + operations = [ + migrations.RenameModel( + old_name='Roles', + new_name='Credits', + ), + migrations.AlterModelOptions( + name='credits', + options={'ordering': ['creator__name'], 'verbose_name_plural': 'Credits'}, + ), + ] diff --git a/comics/models.py b/comics/models.py index ce9693d..4238e06 100644 --- a/comics/models.py +++ b/comics/models.py @@ -6,16 +6,6 @@ from solo.models import SingletonModel -YEAR_CHOICES = [(r, r) for r in range(1837, datetime.date.today().year + 1)] - -# Comic read status -STATUS_CHOICES = ( - (0, 'Unread'), - (1, 'Partially Read'), - (2, 'Read'), -) - - class Settings(SingletonModel): help_str = ('A 40-character key provided by ComicVine. ' 'This is used to retrieve metadata about your comics. ' @@ -151,6 +141,9 @@ class Meta: class Series(models.Model): + YEAR_CHOICES = [(r, r) + for r in range(1837, datetime.date.today().year + 1)] + cvid = models.PositiveIntegerField('Comic Vine ID', unique=True) cvurl = models.URLField('Comic Vine URL', max_length=200, blank=True) name = models.CharField('Series Name', max_length=200) @@ -181,6 +174,12 @@ class Meta: class Issue(models.Model): + STATUS_CHOICES = ( + (0, 'Unread'), + (1, 'Partially Read'), + (2, 'Read'), + ) + cvid = models.PositiveIntegerField('ComicVine ID', unique=True) cvurl = models.URLField('ComicVine URL', max_length=200, blank=True) series = models.ForeignKey(Series, on_delete=models.CASCADE, blank=True) @@ -227,7 +226,7 @@ def __str__(self): return self.name -class Roles(models.Model): +class Credits(models.Model): creator = models.ForeignKey(Creator, on_delete=models.CASCADE) issue = models.ForeignKey(Issue, on_delete=models.CASCADE) role = models.ManyToManyField(Role) @@ -236,5 +235,5 @@ def __str__(self): return self.issue.series.name + ' #' + str(self.issue.number) + ' - ' + self.creator.name class Meta: - verbose_name_plural = "Roles" + verbose_name_plural = "Credits" ordering = ['creator__name'] diff --git a/comics/utils/comicimporter.py b/comics/utils/comicimporter.py index c6c4338..eab9358 100644 --- a/comics/utils/comicimporter.py +++ b/comics/utils/comicimporter.py @@ -16,7 +16,7 @@ import requests_cache from comics.models import (Arc, Character, Creator, Issue, - Publisher, Role, Roles, Series, + Publisher, Role, Credits, Series, Team, Settings) from . import utils @@ -589,7 +589,7 @@ def addComicFromMetadata(self, md): creator_obj, c_create = Creator.objects.get_or_create( cvid=p['id'],) - role_obj = Roles.objects.create( + role_obj = Credits.objects.create( creator=creator_obj, issue=issue_obj) roles = p['role'].split(',') diff --git a/comics/views/creator.py b/comics/views/creator.py index 6017294..f4a0144 100644 --- a/comics/views/creator.py +++ b/comics/views/creator.py @@ -4,7 +4,7 @@ from django.db.models import Q from django.views.generic import ListView, DetailView -from comics.models import Creator, Roles, Issue +from comics.models import Creator, Credits, Issue PAGINATE = 30 @@ -20,9 +20,9 @@ class CreatorDetail(DetailView): def get_context_data(self, **kwargs): context = super(CreatorDetail, self).get_context_data(**kwargs) creator = self.get_object() - roles = Roles.objects.filter(creator=creator) + issue_credits = Credits.objects.filter(creator=creator) context['issue_list'] = Issue.objects.filter( - id__in=roles.values('issue_id')) + id__in=issue_credits.values('issue_id')) return context diff --git a/comics/views/issue.py b/comics/views/issue.py index c759402..0c290f1 100644 --- a/comics/views/issue.py +++ b/comics/views/issue.py @@ -2,7 +2,7 @@ from django.shortcuts import get_object_or_404, render from django.views.generic import DetailView, ListView -from comics.models import Issue, Roles +from comics.models import Issue, Credits from comics.utils.reader import ImageAPIHandler @@ -23,7 +23,7 @@ class IssueDetail(DetailView): def get_context_data(self, **kwargs): context = super(IssueDetail, self).get_context_data(**kwargs) issue = self.get_object() - context['roles_list'] = Roles.objects.filter(issue=issue) + context['roles_list'] = Credits.objects.filter(issue=issue) return context