From: Aleksander Ɓukasz Date: Mon, 6 May 2013 13:48:29 +0000 (+0200) Subject: wip: a first shot at libraries catalog X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/bc7619edc01175ed32c2155a19fba22ddb8365ce?ds=sidebyside;hp=340b7f2a6d8a552399511cc87747d1223df48ec0 wip: a first shot at libraries catalog --- diff --git a/apps/libraries/__init__.py b/apps/libraries/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/apps/libraries/admin.py b/apps/libraries/admin.py new file mode 100644 index 000000000..c43dd6a35 --- /dev/null +++ b/apps/libraries/admin.py @@ -0,0 +1,6 @@ +from django.contrib import admin + +from libraries.models import Library + + +admin.site.register(Library) \ No newline at end of file diff --git a/apps/libraries/locale/pl/LC_MESSAGES/django.mo b/apps/libraries/locale/pl/LC_MESSAGES/django.mo new file mode 100644 index 000000000..d8c29f1b0 Binary files /dev/null and b/apps/libraries/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/libraries/locale/pl/LC_MESSAGES/django.po b/apps/libraries/locale/pl/LC_MESSAGES/django.po new file mode 100644 index 000000000..57653b8fd --- /dev/null +++ b/apps/libraries/locale/pl/LC_MESSAGES/django.po @@ -0,0 +1,44 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2013-05-06 15:42+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" + +#: models.py:8 +msgid "name" +msgstr "nazwa" + +#: models.py:9 +msgid "url" +msgstr "url" + +#: models.py:10 +msgid "description" +msgstr "opis" + +#: models.py:13 +msgid "library" +msgstr "biblioteka" + +#: models.py:14 +msgid "libraries" +msgstr "biblioteki" + +#: templates/libraries/main_view.html:4 templates/libraries/main_view.html:8 +msgid "Libraries directory" +msgstr "Katalog bibliotek" diff --git a/apps/libraries/migrations/0001_initial.py b/apps/libraries/migrations/0001_initial.py new file mode 100644 index 000000000..0411c878a --- /dev/null +++ b/apps/libraries/migrations/0001_initial.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +import datetime +from south.db import db +from south.v2 import SchemaMigration +from django.db import models + + +class Migration(SchemaMigration): + + def forwards(self, orm): + # Adding model 'Library' + db.create_table(u'libraries_library', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(max_length=120, blank=True)), + ('url', self.gf('django.db.models.fields.CharField')(max_length=120, blank=True)), + ('description', self.gf('django.db.models.fields.TextField')(blank=True)), + )) + db.send_create_signal(u'libraries', ['Library']) + + + def backwards(self, orm): + # Deleting model 'Library' + db.delete_table(u'libraries_library') + + + models = { + u'libraries.library': { + 'Meta': {'object_name': 'Library'}, + 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}), + 'url': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}) + } + } + + complete_apps = ['libraries'] \ No newline at end of file diff --git a/apps/libraries/migrations/__init__.py b/apps/libraries/migrations/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/apps/libraries/models.py b/apps/libraries/models.py new file mode 100644 index 000000000..d8a54a8a5 --- /dev/null +++ b/apps/libraries/models.py @@ -0,0 +1,21 @@ +from django.db import models +from django.utils.translation import ugettext_lazy as _ + +class Library(models.Model): + """Represent a single library in the libraries dictionary""" + + #slug = models.SlugField(_('slug'), max_length=120, unique=True, db_index=True) + name = models.CharField(_('name'), max_length=120, blank=True) + url = models.CharField(_('url'), max_length=120, blank=True) + description = models.TextField(_('description'), blank=True) + + class Meta: + verbose_name = _('library') + verbose_name_plural = _('libraries') + + def __unicode__(self): + return self.name + + @models.permalink + def get_absolute_url(self): + return ('infopage', [self.slug]) diff --git a/apps/libraries/static/libraries/libraries.css b/apps/libraries/static/libraries/libraries.css new file mode 100644 index 000000000..963e3badc --- /dev/null +++ b/apps/libraries/static/libraries/libraries.css @@ -0,0 +1,16 @@ +.libraries-list { + margin: 10px 0; +} + +.libraries-list-item { + margin: 10px 0; +} + +.libraries-list-item { + margin: 10px 0; + font-size: 1.3em; +} + +.libraries-list-item-header { + font-size: 1.2em; +} \ No newline at end of file diff --git a/apps/libraries/templates/libraries/main_view.html b/apps/libraries/templates/libraries/main_view.html new file mode 100644 index 000000000..9e16b1911 --- /dev/null +++ b/apps/libraries/templates/libraries/main_view.html @@ -0,0 +1,22 @@ +{% extends "base.html" %} +{% load i18n %} + +{% block titleextra %}{% trans 'Libraries directory' %}{% endblock %} + + +{% block body %} +

{% trans 'Libraries directory' %}

+ +
+ {% for library in libraries %} +
+ +
+ + {% autoescape off %}{{library.description}}{% endautoescape%} +
+
+ {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/apps/libraries/urls.py b/apps/libraries/urls.py new file mode 100644 index 000000000..a3d90316b --- /dev/null +++ b/apps/libraries/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls.defaults import * + + +urlpatterns = patterns('libraries.views', + url(r'^$', 'main_view', name='libraries_main_view'), +) \ No newline at end of file diff --git a/apps/libraries/views.py b/apps/libraries/views.py new file mode 100644 index 000000000..d75c8b468 --- /dev/null +++ b/apps/libraries/views.py @@ -0,0 +1,11 @@ +from django.shortcuts import render_to_response, get_object_or_404 +from django.template import RequestContext, Template, TemplateSyntaxError + +from libraries.models import Library + + +def main_view(request): + context = RequestContext(request) + context['libraries'] = Library.objects.all() + + return render_to_response('libraries/main_view.html', context_instance = context) \ No newline at end of file diff --git a/wolnelektury/settings/__init__.py b/wolnelektury/settings/__init__.py index 8fdb97399..e5c7ece10 100644 --- a/wolnelektury/settings/__init__.py +++ b/wolnelektury/settings/__init__.py @@ -67,6 +67,7 @@ INSTALLED_APPS_OUR = [ 'waiter', 'search', 'oai', + 'libraries', ] INSTALLED_APPS_CONTRIB = [ diff --git a/wolnelektury/settings/static.py b/wolnelektury/settings/static.py index 4e104c4e7..aaa70c645 100644 --- a/wolnelektury/settings/static.py +++ b/wolnelektury/settings/static.py @@ -30,6 +30,7 @@ PIPELINE_CSS = { 'css/catalogue.css', 'sponsors/css/sponsors.css', 'css/auth.css', + 'libraries/libraries.css', 'css/social/shelf_tags.css', 'css/ui-lightness/jquery-ui-1.8.16.custom.css', diff --git a/wolnelektury/urls.py b/wolnelektury/urls.py index 7224b20ed..980173371 100644 --- a/wolnelektury/urls.py +++ b/wolnelektury/urls.py @@ -35,6 +35,7 @@ urlpatterns += patterns('', url(r'^ludzie/', include('social.urls')), url(r'^uzytkownik/', include('allauth.urls')), url(r'^czekaj/', include('waiter.urls')), + url(r'^biblioteki/', include('libraries.urls')), # Admin panel url(r'^admin/catalogue/book/import$', 'catalogue.views.import_book', name='import_book'),