From dc3268aec8f54f328ba02019b83a6a082af0809a Mon Sep 17 00:00:00 2001 From: Felipe Martin Date: Fri, 28 Mar 2014 15:48:05 +0100 Subject: [PATCH] + Added base series.list and series.detail pages (views / urls) + Added Publisher.url field + Base ordering for models --- gruntfile.coffee | 2 +- .../0003_auto__add_field_publisher_url.py | 51 +++++++++++++++++++ shelfzilla/apps/manga/models.py | 4 ++ shelfzilla/apps/manga/urls/__init__.py | 0 shelfzilla/apps/manga/urls/series.py | 9 ++++ shelfzilla/apps/manga/views/__init__.py | 0 shelfzilla/apps/manga/views/series.py | 35 +++++++++++++ shelfzilla/models.py | 4 ++ shelfzilla/settings/local.py | 5 ++ .../themes/bootflat/static/less/fixes.less | 3 +- .../themes/bootflat/static/less/layout.less | 10 ++++ .../themes/bootflat/templates/_layout.html | 2 +- .../templates/manga/series/detail.html | 41 +++++++++++++++ .../bootflat/templates/manga/series/list.html | 29 +++++++++++ shelfzilla/urls.py | 1 + shelfzilla/views.py | 13 +++++ 16 files changed, 206 insertions(+), 3 deletions(-) create mode 100644 shelfzilla/apps/manga/migrations/0003_auto__add_field_publisher_url.py create mode 100644 shelfzilla/apps/manga/urls/__init__.py create mode 100644 shelfzilla/apps/manga/urls/series.py create mode 100644 shelfzilla/apps/manga/views/__init__.py create mode 100644 shelfzilla/apps/manga/views/series.py create mode 100644 shelfzilla/themes/bootflat/templates/manga/series/detail.html create mode 100644 shelfzilla/themes/bootflat/templates/manga/series/list.html create mode 100644 shelfzilla/views.py diff --git a/gruntfile.coffee b/gruntfile.coffee index edafe7c..9c7f75d 100644 --- a/gruntfile.coffee +++ b/gruntfile.coffee @@ -82,7 +82,7 @@ module.exports = (grunt) -> options: livereload: true layout: - files: ['shelfzilla/themes/bootflat/templates/**/*.html', 'shelfzilla/themes/bootflat/templates/**/*.jinja'] + files: ['shelfzilla/themes/**/*.html', 'shelfzilla/themes/**/*.jinja'] tasks: [] less: files: ['shelfzilla/themes/bootflat/static/less/*.less'] diff --git a/shelfzilla/apps/manga/migrations/0003_auto__add_field_publisher_url.py b/shelfzilla/apps/manga/migrations/0003_auto__add_field_publisher_url.py new file mode 100644 index 0000000..5d0d227 --- /dev/null +++ b/shelfzilla/apps/manga/migrations/0003_auto__add_field_publisher_url.py @@ -0,0 +1,51 @@ +# -*- coding: utf-8 -*- +from south.utils import datetime_utils as datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding field 'Publisher.url' + db.add_column(u'manga_publisher', 'url', + self.gf('django.db.models.fields.URLField')(max_length=200, null=True, blank=True), + keep_default=False) + + + def backwards(self, orm): + # Deleting field 'Publisher.url' + db.delete_column(u'manga_publisher', 'url') + + + models = { + u'manga.publisher': { + 'Meta': {'ordering': "['name']", 'object_name': 'Publisher'}, + 'for_review': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'for_review_comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}), + 'url': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}) + }, + u'manga.series': { + 'Meta': {'ordering': "['name']", 'object_name': 'Series'}, + 'for_review': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'for_review_comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '40'}) + }, + u'manga.volume': { + 'Meta': {'ordering': "['series__name', 'number']", 'object_name': 'Volume'}, + 'for_review': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'for_review_comment': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'isbn_10': ('django.db.models.fields.CharField', [], {'max_length': '10', 'null': 'True', 'blank': 'True'}), + 'isbn_13': ('django.db.models.fields.CharField', [], {'max_length': '13', 'null': 'True', 'blank': 'True'}), + 'number': ('django.db.models.fields.IntegerField', [], {}), + 'publisher': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'volumes'", 'to': u"orm['manga.Publisher']"}), + 'series': ('django.db.models.fields.related.ForeignKey', [], {'related_name': "'volumes'", 'to': u"orm['manga.Series']"}) + } + } + + complete_apps = ['manga'] \ No newline at end of file diff --git a/shelfzilla/apps/manga/models.py b/shelfzilla/apps/manga/models.py index 79293de..4f36d76 100644 --- a/shelfzilla/apps/manga/models.py +++ b/shelfzilla/apps/manga/models.py @@ -6,6 +6,7 @@ from shelfzilla.models import ReviewModel class Publisher(ReviewModel): name = models.CharField(_('Name'), max_length=40) + url = models.URLField(_('URL'), blank=True, null=True) def __unicode__(self): return u'{}'.format(self.name) @@ -15,6 +16,7 @@ class Publisher(ReviewModel): return self.volumes.distinct('series') class Meta: + ordering = ['name'] verbose_name = _('Publisher') verbose_name_plural = _('Publishers') @@ -30,6 +32,7 @@ class Series(ReviewModel): return self.volumes.distinct('publisher') class Meta: + ordering = ['name'] verbose_name = _('Series') verbose_name_plural = _('Series') @@ -47,5 +50,6 @@ class Volume(ReviewModel): return u'{} #{}'.format(self.series.name, self.number) class Meta: + ordering = ['series__name', 'number'] verbose_name = _('Volume') verbose_name_plural = _('Volumes') diff --git a/shelfzilla/apps/manga/urls/__init__.py b/shelfzilla/apps/manga/urls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/shelfzilla/apps/manga/urls/series.py b/shelfzilla/apps/manga/urls/series.py new file mode 100644 index 0000000..1c35cb9 --- /dev/null +++ b/shelfzilla/apps/manga/urls/series.py @@ -0,0 +1,9 @@ +from django.conf.urls import patterns, url + +from ..views.series import SeriesListView, SeriesDetailView + +urlpatterns = patterns( + '', + url(r'^$', SeriesListView.as_view(), name='series.list'), + url(r'^(?P\d+)/$', SeriesDetailView.as_view(), name='series.detail'), +) diff --git a/shelfzilla/apps/manga/views/__init__.py b/shelfzilla/apps/manga/views/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/shelfzilla/apps/manga/views/series.py b/shelfzilla/apps/manga/views/series.py new file mode 100644 index 0000000..b001144 --- /dev/null +++ b/shelfzilla/apps/manga/views/series.py @@ -0,0 +1,35 @@ +from django.template import RequestContext +from django.shortcuts import render_to_response, get_object_or_404 + +from shelfzilla.views import View +from ..models import Series + + +class SeriesView(View): + section = 'series' + + +class SeriesListView(SeriesView): + template = 'manga/series/list.html' + + def get(self, request): + items = Series.objects.all() + context = { + 'items': items + } + ctx = RequestContext(request, self.get_context(context)) + return render_to_response(self.template, context_instance=ctx) + + +class SeriesDetailView(SeriesView): + template = 'manga/series/detail.html' + + def get(self, request, sid): + item = get_object_or_404(Series, pk=sid) + + context = { + 'item': item + } + + ctx = RequestContext(request, self.get_context(context)) + return render_to_response(self.template, context_instance=ctx) diff --git a/shelfzilla/models.py b/shelfzilla/models.py index a998cda..193e5cc 100644 --- a/shelfzilla/models.py +++ b/shelfzilla/models.py @@ -7,5 +7,9 @@ class ReviewModel(models.Model): for_review_comment = models.TextField( _('Review comment'), null=True, blank=True) + def first_letter(self): + if hasattr(self, 'name'): + return self.name and self.name[0] or '' + class Meta: abstract = True diff --git a/shelfzilla/settings/local.py b/shelfzilla/settings/local.py index a832472..180c116 100644 --- a/shelfzilla/settings/local.py +++ b/shelfzilla/settings/local.py @@ -13,3 +13,8 @@ DATABASES = { STATICFILES_DIRS += ( os.path.join(BASE_DIR, "..", "static_components"), ) + +# Apps +INSTALLED_APPS += ( + 'django.contrib.webdesign', +) diff --git a/shelfzilla/themes/bootflat/static/less/fixes.less b/shelfzilla/themes/bootflat/static/less/fixes.less index 4bfcaa6..8792c54 100644 --- a/shelfzilla/themes/bootflat/static/less/fixes.less +++ b/shelfzilla/themes/bootflat/static/less/fixes.less @@ -1,6 +1,7 @@ -// jquery vegas, background with opacity +// jquery vegas, background with opacity, not overlaying .vegas-background { opacity: .3; + z-index: -200; } // bootstrap navbar, margin-top diff --git a/shelfzilla/themes/bootflat/static/less/layout.less b/shelfzilla/themes/bootflat/static/less/layout.less index d4e3800..13b54d0 100644 --- a/shelfzilla/themes/bootflat/static/less/layout.less +++ b/shelfzilla/themes/bootflat/static/less/layout.less @@ -1,3 +1,7 @@ +body { + background-color: rgb(241, 242, 246); +} + /* Login panel */ .panel-login { @height: 180px; @@ -12,3 +16,9 @@ top: 50%; width: 300px; } + +/* Alternative behaviours for bootstrap */ +.panel-title-alt { + font-size: 1.75em !important; + font-weight: bold; +} diff --git a/shelfzilla/themes/bootflat/templates/_layout.html b/shelfzilla/themes/bootflat/templates/_layout.html index 604cd6f..8ee13a0 100644 --- a/shelfzilla/themes/bootflat/templates/_layout.html +++ b/shelfzilla/themes/bootflat/templates/_layout.html @@ -24,7 +24,7 @@