From: Aleksander Ɓukasz Date: Wed, 16 Oct 2013 10:05:30 +0000 (+0200) Subject: Browsing and showing comment documents X-Git-Url: https://git.mdrn.pl/edumed.git/commitdiff_plain/9beb8b9bcc4902c8100f4ecf28d4e025e99a4195?hp=ab456c38cd1974163ac4a390756770687297aaab Browsing and showing comment documents --- diff --git a/comment/__init__.py b/comment/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/comment/admin.py b/comment/admin.py new file mode 100644 index 0000000..8b3cbd5 --- /dev/null +++ b/comment/admin.py @@ -0,0 +1,9 @@ +from django.contrib import admin + +from .models import CommentDocument + + +class CommentDocumentAdmin(admin.ModelAdmin): + prepopulated_fields = {"slug": ("name",)} + +admin.site.register(CommentDocument, CommentDocumentAdmin) diff --git a/comment/migrations/0001_initial.py b/comment/migrations/0001_initial.py new file mode 100644 index 0000000..9bf33a5 --- /dev/null +++ b/comment/migrations/0001_initial.py @@ -0,0 +1,38 @@ +# -*- 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 'CommentDocument' + db.create_table(u'comment_commentdocument', ( + (u'id', self.gf('django.db.models.fields.AutoField')(primary_key=True)), + ('name', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), + ('slug', self.gf('django.db.models.fields.SlugField')(unique=True, max_length=255)), + ('comment_id', self.gf('django.db.models.fields.CharField')(unique=True, max_length=255)), + ('order', self.gf('django.db.models.fields.IntegerField')()), + )) + db.send_create_signal(u'comment', ['CommentDocument']) + + + def backwards(self, orm): + # Deleting model 'CommentDocument' + db.delete_table(u'comment_commentdocument') + + + models = { + u'comment.commentdocument': { + 'Meta': {'ordering': "['order']", 'object_name': 'CommentDocument'}, + 'comment_id': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + u'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'name': ('django.db.models.fields.CharField', [], {'unique': 'True', 'max_length': '255'}), + 'order': ('django.db.models.fields.IntegerField', [], {}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '255'}) + } + } + + complete_apps = ['comment'] \ No newline at end of file diff --git a/comment/migrations/__init__.py b/comment/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/comment/models.py b/comment/models.py new file mode 100644 index 0000000..a5c3000 --- /dev/null +++ b/comment/models.py @@ -0,0 +1,18 @@ +from django.db import models +from django.core.urlresolvers import reverse + + +class CommentDocument(models.Model): + name = models.CharField(max_length = 255, unique = True) + slug = models.SlugField(max_length = 255, unique = True) + comment_id = models.CharField(max_length = 255, unique = True) + order = models.IntegerField() + + class Meta: + ordering = ['order'] + + def __unicode__(self): + return self.name + + def get_absolute_url(self): + return reverse('comment_document', kwargs = dict(slug = self.slug)) diff --git a/comment/templates/comment/commentdocument_detail.html b/comment/templates/comment/commentdocument_detail.html new file mode 100644 index 0000000..2ab214b --- /dev/null +++ b/comment/templates/comment/commentdocument_detail.html @@ -0,0 +1,9 @@ +{% extends "base_mil.html" %} + +{% block body %} + +

{{object.name}}

+ + + +{% endblock %} \ No newline at end of file diff --git a/comment/templates/comment/commentdocument_list.html b/comment/templates/comment/commentdocument_list.html new file mode 100644 index 0000000..41d115b --- /dev/null +++ b/comment/templates/comment/commentdocument_list.html @@ -0,0 +1,12 @@ +{% extends "base_mil.html" %} + + +{% block body %} + +
    + {% for document in object_list %} +
  1. {{document.name}}
  2. + {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/comment/urls.py b/comment/urls.py new file mode 100644 index 0000000..fcc7d99 --- /dev/null +++ b/comment/urls.py @@ -0,0 +1,9 @@ +from django.conf.urls import patterns, include, url + +from .views import CommentDocumentList, CommentDocument + + +urlpatterns = patterns('', + url('^$', CommentDocumentList.as_view(), name = 'comment_document_index'), + url('^(?P[^/]+)/$', CommentDocument.as_view(), name = 'comment_document') +) \ No newline at end of file diff --git a/comment/views.py b/comment/views.py new file mode 100644 index 0000000..748f9c4 --- /dev/null +++ b/comment/views.py @@ -0,0 +1,17 @@ +from django.views.generic import ListView, DetailView +from django.conf import settings + +from .models import CommentDocument + + +class CommentDocumentList(ListView): + model = CommentDocument + + +class CommentDocument(DetailView): + model = CommentDocument + + def get_context_data(self, **kwargs): + context = super(CommentDocument, self).get_context_data(**kwargs) + context['comment_url'] = settings.COMMENT_URL + return context \ No newline at end of file diff --git a/edumed/milurls.py b/edumed/milurls.py index 8f9060c..89a65c5 100644 --- a/edumed/milurls.py +++ b/edumed/milurls.py @@ -7,6 +7,7 @@ from .views import MILHomeView urlpatterns = i18n_patterns('', url(r'^$', MILHomeView.as_view(), name="mil_home"), url(r'^kompetencje/', include('curriculum.urls')), + url(r'^wez-udzial/', include('comment.urls')) ) handler404 = 'edumed.views.mil_404_view' diff --git a/edumed/settings.d/30-apps.py b/edumed/settings.d/30-apps.py index 1f9fdb8..7091ff1 100644 --- a/edumed/settings.d/30-apps.py +++ b/edumed/settings.d/30-apps.py @@ -2,6 +2,7 @@ INSTALLED_APPS = ( 'edumed', 'curriculum', 'catalogue', + 'comment', 'fnpdjango', 'south',