Skip to content
This repository has been archived by the owner on Apr 21, 2019. It is now read-only.

Commit

Permalink
Renamed Roles model to Credits model. Fixes #22
Browse files Browse the repository at this point in the history
* Also mode Issue & Sereis choices to appropriate models.
* This commit should be the final one needed to remove the MultileSleectField from the models. Project should now be able to dumpdata w/o erroring out.
  • Loading branch information
bpepple committed Jan 20, 2018
1 parent a91009c commit 5af5f10
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 19 deletions.
21 changes: 21 additions & 0 deletions comics/migrations/0008_rename_roles_to_credits.py
Original file line number Diff line number Diff line change
@@ -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'},
),
]
23 changes: 11 additions & 12 deletions comics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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. '
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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']
4 changes: 2 additions & 2 deletions comics/utils/comicimporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(',')
Expand Down
6 changes: 3 additions & 3 deletions comics/views/creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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


Expand Down
4 changes: 2 additions & 2 deletions comics/views/issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand All @@ -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


Expand Down

0 comments on commit 5af5f10

Please sign in to comment.