Browsing and showing comment documents
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 16 Oct 2013 10:05:30 +0000 (12:05 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 22 Oct 2013 07:49:53 +0000 (09:49 +0200)
comment/__init__.py [new file with mode: 0644]
comment/admin.py [new file with mode: 0644]
comment/migrations/0001_initial.py [new file with mode: 0644]
comment/migrations/__init__.py [new file with mode: 0644]
comment/models.py [new file with mode: 0644]
comment/templates/comment/commentdocument_detail.html [new file with mode: 0644]
comment/templates/comment/commentdocument_list.html [new file with mode: 0644]
comment/urls.py [new file with mode: 0644]
comment/views.py [new file with mode: 0644]
edumed/milurls.py
edumed/settings.d/30-apps.py

diff --git a/comment/__init__.py b/comment/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/comment/admin.py b/comment/admin.py
new file mode 100644 (file)
index 0000000..8b3cbd5
--- /dev/null
@@ -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 (file)
index 0000000..9bf33a5
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
diff --git a/comment/models.py b/comment/models.py
new file mode 100644 (file)
index 0000000..a5c3000
--- /dev/null
@@ -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 (file)
index 0000000..2ab214b
--- /dev/null
@@ -0,0 +1,9 @@
+{% extends "base_mil.html" %}
+
+{% block body %}
+
+    <h1>{{object.name}}</h1>
+
+    <iframe  frameborder="0" src="{{comment_url}}/text/{{object.comment_id}}/comments_frame/?" style="height: 600px; width: 99.9%; position: relative; top: 0px;"></iframe>
+
+{% 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 (file)
index 0000000..41d115b
--- /dev/null
@@ -0,0 +1,12 @@
+{% extends "base_mil.html" %}
+
+
+{% block body %}
+
+    <ol>
+    {% for document in object_list %}
+        <li><a href="{{document.get_absolute_url}}">{{document.name}}</a></li>
+    {% endfor %}
+    </ol>
+
+{% endblock %}
\ No newline at end of file
diff --git a/comment/urls.py b/comment/urls.py
new file mode 100644 (file)
index 0000000..fcc7d99
--- /dev/null
@@ -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<slug>[^/]+)/$', 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 (file)
index 0000000..748f9c4
--- /dev/null
@@ -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
index 8f9060c..89a65c5 100644 (file)
@@ -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'
index 1f9fdb8..7091ff1 100644 (file)
@@ -2,6 +2,7 @@ INSTALLED_APPS = (
     'edumed',
     'curriculum',
     'catalogue',
+    'comment',
 
     'fnpdjango',
     'south',