Added:
/trunk/pirate-politics/pirate_comments
/trunk/pirate-politics/pirate_comments/__init__.py
/trunk/pirate-politics/pirate_comments/models.py
/trunk/pirate-politics/pirate_comments/templatetags
/trunk/pirate-politics/pirate_comments/templatetags/__init__.py
/trunk/pirate-politics/pirate_comments/templatetags/commenttags.py
/trunk/pirate-politics/pirate_comments/tests.py
/trunk/pirate-politics/pirate_comments/views.py
Modified:
/trunk/pirate-politics/new_templates/_issue.html
/trunk/pirate-politics/new_templates/_rightcol.html
/trunk/pirate-politics/new_templates/_solution.html
/trunk/pirate-politics/new_templates/_sourcetags.html
/trunk/pirate-politics/new_templates/argument_detail.html
/trunk/pirate-politics/new_templates/base.html
/trunk/pirate-politics/new_templates/issue_detail.html
/trunk/pirate-politics/new_templates/issues.html
/trunk/pirate-politics/new_templates/register.html
/trunk/pirate-politics/new_templates/solution_detail.html
/trunk/pirate-politics/new_templates/solutions.html
/trunk/pirate-politics/new_templates/submit_issue.html
/trunk/pirate-politics/new_templates/submit_solution.html
/trunk/pirate-politics/new_templates/tag_detail.html
/trunk/pirate-politics/new_templates/user_profile.html
/trunk/pirate-politics/pirate_consensus/models.py
/trunk/pirate-politics/pirate_core/middleware.py
/trunk/pirate-politics/pirate_core/views.py
/trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
/trunk/pirate-politics/pirate_issues/templatetags/issuetags.py
/trunk/pirate-politics/pirate_issues/templatetags/solutiontags.py
/trunk/pirate-politics/pirate_issues/templatetags/usertags.py
/trunk/pirate-politics/pirate_login/views.py
/trunk/pirate-politics/settings.py
/trunk/pirate-politics/static/style.css
=======================================
--- /dev/null
+++ /trunk/pirate-politics/pirate_comments/models.py Tue Jan 25 15:15:31
2011
@@ -0,0 +1,66 @@
+from django.db import models
+from django import template
+from django.contrib import admin
+from django.contrib.auth.models import User
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.contenttypes import generic
+from treebeard.ns_tree import NS_Node
+
+
+#from ModuleDeliberation.models import Comment
+from django.utils.translation import ugettext as _
+from pirate_core.views import template_for_model
+
+
+class PirateComment(models.Model):
+ user = models.ForeignKey(User)
+ submit_date = models.DateTimeField('date_published',auto_now_add=True)
+ text = models.TextField(max_length=1200)
+ content_type = models.ForeignKey(ContentType,
+ verbose_name=_('content type'),
+
related_name="content_type_set_for_pirate_%(class)s")
+ object_pk = models.IntegerField(_('object ID'))
+ content_object = generic.GenericForeignKey(ct_field="content_type",
fk_field="object_pk")
+ is_leaf = models.BooleanField()
+
+ class Meta:
+ verbose_name = _('comment')
+
+ def __unicode__(self):
+ return self.user.username + ":" + str(self.submit_date)
+
+
+class NSComment(NS_Node):
+ user = models.ForeignKey(User)
+ text = models.TextField()
+
+ #created = models.DateTimeField(auto_now_add=True)
+ # Exception Value: Cannot use None as a query value
+ created = models.DateTimeField(editable=False)
+
+ content_type = models.ForeignKey(ContentType,
+ verbose_name=_('content type'),
+
related_name="content_type_set_for_%(class)s")
+ object_pk = models.IntegerField(_('object ID'))
+ content_object = generic.GenericForeignKey(ct_field="content_type",
fk_field="object_pk")
+
+
+ @models.permalink
+ #This must be added to all classes that can be tagged
+ def get_absolute_url(self):
+ content_type = self.content_type
+ path = template_for_model(str(content_type)) + "?_t=" +
str(content_type.pk) + "&_o=" + str(self.object_pk)
+ return path
+
+ def __unicode__(self):
+ return u'NS_Comment %d: %s' % (self.id, self.text)
+
+ class Meta:
+ verbose_name = _('nscomment')
+
+ # when adding a custom Meta class to a NS model, the ordering must
be
+ # set again
+
+
+admin.site.register(NSComment)
+
=======================================
--- /dev/null
+++ /trunk/pirate-politics/pirate_comments/templatetags/commenttags.py Tue
Jan 25 15:15:31 2011
@@ -0,0 +1,218 @@
+from django import template
+from django import forms
+from django.http import HttpResponse, HttpResponseRedirect
+from django.utils import simplejson
+from pirate_comments.models import PirateComment, NSComment
+from django.db import transaction
+from django.contrib.contenttypes.models import ContentType
+
+import datetime
+
+from django.shortcuts import get_object_or_404
+
+from pirate_core.views import HttpRedirectException, namespace_get
+
+
+from customtags.decorators import block_decorator
+register = template.Library()
+block = block_decorator(register)
+
+get_namespace = namespace_get('pp_comment')
+
+@block
+def pp_load_comments(context, nodelist, *args, **kwargs):
+
+ context.push()
+ namespace = get_namespace(context)
+
+ obj = kwargs.pop('object', None)
+ node_id = kwargs.pop('node_id',None)
+
+ if obj is None:
+ raise ValueError("pp_consensus_get tag requires that a consensus
object be passed "
+ "to it assigned to the 'object=' argument,
and that the str "
+ "be assigned the string value 'consensus.")
+ user = kwargs.pop('user', None)
+
+ if node_id:
+ root = get_object_or_404(NSComment, id=node_id)
+ if root.get_depth() != 1:
+ # meh not really a root node, redirecting...
+ raise
HttpRedirectException(HttpResponseRedirect(obj.get_absolute_url()))
+ else:
+ root = None
+
+ if node_id:
+ descendants = root.get_descendants()
+ nodes = [(root, len(descendants))] + [
+ (node, node.get_children_count())
+ for node in descendants
+ ]
+ namespace['mainpage'] = False
+ namespace['nodes'] = nodes
+
+ else:
+ namespace['mainpage'] = True
+ nodes = NSComment.objects.all()
+ nodes = nodes.filter(object_pk=obj.pk)
+ namespace['nodes'] = [(node, node.get_descendant_count())
+ for node in nodes if node.get_depth() == 1]
+ namespace['total_comments'] = len(namespace['nodes']) + \
+ sum([count for _, count in
namespace['nodes']])
+ namespace['treetype'] = 'ns'
+
+
+ output = nodelist.render(context)
+ context.pop()
+
+ return output
+
+@block
+def pp_comment_list_get(context, nodelist, *args, **kwargs):
+
+ #load nested comments from treebeard
+ context.push()
+ namespace = get_namespace(context)
+
+ object_pk = kwargs.pop('object', None)
+ if object_pk is None:
+ raise ValueError("pp_consensus_get tag requires that a consensus
object be passed "
+ "to it assigned to the 'object=' argument,
and that the str "
+ "be assigned the string value 'consensus.")
+ user = kwargs.pop('user', None)
+
+ comments = Comment.objects.all()
+ comments = comments.filter(object_pk=object_pk)
+
+
+ namespace['comments'] = comments
+
+ output = nodelist.render(context)
+ context.pop()
+
+ return output
+
+@block
+def pp_comment_form2(context, nodelist, *args, **kwargs):
+
+ context.push()
+ namespace = get_namespace(context)
+
+ POST = kwargs.get('POST', None)
+ path = kwargs.get('path', None)
+ obj = kwargs.get('object',None)
+ comment = kwargs.get('edit',None)
+ user = kwargs.get('user', None)
+ tbmodel = NSComment
+
+ if obj == None:
+ raise ValueException("The designer must specify 'object' to the
form of type models.Model ")
+ if user == None:
+ raise ValueException("The designer must specify one of 'user',
generally request.user ")
+
+ if isinstance(obj, NSComment):
+ root = obj
+ else:
+ root = None
+
+ if POST and POST.get("form_id") == "pp_comment_form":
+
+ form = CommentForm(POST) if comment is None else CommentForm(POST,
instance=comment)
+
+ c_type = ContentType.objects.get_for_model(obj.__class__)
+
+ if form.is_valid():
+ if root == None:
+ com = NSComment.add_root(
+ user=user,
+ text=form.cleaned_data['text'],
+ created=datetime.datetime.now(),
+ content_type=c_type,
+ object_pk = obj.pk)
+ else:
+ com = root.add_child(
+ user=form.cleaned_data['user'],
+ text=form.cleaned_data['text'],
+ created=datetime.datetime.now(),
+ content_type=c_type,
+ object_pk = obj.pk)
+
+ if not root:
+ root = com
+
+ raise
HttpRedirectException(HttpResponseRedirect(obj.get_absolute_url()))
+ else:
+ form = CommentForm() if comment is None else
CommentForm(instance=comment)
+
+ namespace['form'] = form
+ output = nodelist.render(context)
+ context.pop()
+
+ return output
+
+
+
+@block
+def pp_comment_form(context, nodelist, *args, **kwargs):
+ '''
+ This block tag can create or process forms either to create or to
modify issues.
+ Usage is as follows:
+
+ {% pp_comment_form POST=request.POST path=request.path
object=request.object user=request.user %}
+ Do stuff with {{ pp-comment.form }}.
+ {% endpp_comment_form %}
+ '''
+
+ context.push()
+ namespace = get_namespace(context)
+
+ POST = kwargs.get('POST', None)
+ path = kwargs.get('path', None)
+ obj = kwargs.get('object',None)
+ user = kwargs.get('user', None)
+
+ if isinstance(obj, Comment):
+ comment = obj
+ else:
+ comment = None
+ if POST and POST.get("form_id") == "pp_comment_form":
+ form = CommentForm(POST) if comment is None else CommentForm(POST,
instance=comment)
+ comment = form.save(commit=False)
+ comment.user = user
+ c_type = ContentType.objects.get_for_model(obj.__class__)
+ comment.content_type = c_type
+ comment.object_pk = obj.pk
+ comment.is_leaf = False
+ comment.save()
+
+ raise
HttpRedirectException(HttpResponseRedirect(obj.get_absolute_url()))
+
+ else: form = CommentForm() if comment is None else
CommentForm(instance=comment)
+
+
+ namespace['form'] = form
+ output = nodelist.render(context)
+ context.pop()
+
+ return output
+
+class CommentForm(forms.Form):
+ '''
+ This form is used to allow creation and modification of comment
objects.
+ It extends FormMixin in order to provide a create() class method, which
+ is used to process POST, path, and object variables in a consistant
way,
+ and in order to automatically provide the form with a form_id.
+ '''
+
+ def save(self, commit=True):
+ new_comment = super(CommentForm, self).save(commit=commit)
+ return new_comment
+
+ #need to grab user from authenticatio
+ form_id = forms.CharField(widget=forms.HiddenInput(),
initial="pp_comment_form")
+ text = forms.CharField(widget=forms.Textarea)
+ parent = forms.IntegerField(label='Parent',
+ required=False,
+ widget=forms.HiddenInput)
+
+
=======================================
--- /dev/null
+++ /trunk/pirate-politics/pirate_comments/tests.py Tue Jan 25 15:15:31 2011
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
=======================================
--- /dev/null
+++ /trunk/pirate-politics/pirate_comments/views.py Tue Jan 25 15:15:31 2011
@@ -0,0 +1,1 @@
+# Create your views here.
=======================================
--- /trunk/pirate-politics/new_templates/_issue.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/_issue.html Tue Jan 25 15:15:31
2011
@@ -4,7 +4,6 @@
{% load consensustags %}
{% load argumenttags %}
{% load solutiontags %}
-{% load comments %}
{% if iss_obj %}
@@ -44,8 +43,8 @@
<a href="{% pp_url template='solutions.html' object=iss_obj
dimension=dimension %}">see {{ iss_obj.solutions }} solution{{
iss_obj.solutions|pluralize }}...</a>
</div>
<div class="col3">
- {% get_comment_count
for iss_obj as comment_count %}
- {{comment_count}} comment{{comment_count|pluralize }}
+
+ 0 comments
</div>
</div>
</div>
=======================================
--- /trunk/pirate-politics/new_templates/_rightcol.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/_rightcol.html Tue Jan 25 15:15:31
2011
@@ -10,7 +10,7 @@
<ul class="d">
<div id="login" style="display:none; overflow:hidden; height:75px;">
- {% pp_user_login_form POST=request.POST path=request.path
request=request %}
+ {% pp_user_login_form POST=request.POST path=request.path
request=request object=request.object %}
{{ pp_login.form.errors }}
<form method="post" action="">
<li>name: {{ pp_login.form.name }}</li>
@@ -31,33 +31,5 @@
{% endfor %}
</ul>
{% endif %}
-
- {% if request.object.taggable %}
- <ul class="d">
- <b>Tags:</b> {% if request.user.is_authenticated and
request.object %}<a href="javascript:;"
onmousedown="toggleSlide('tag_rightcol');">+tag</a>{% endif %}
- {% pp_get_tags_for_object object=request.object %}
- {% for tag in pp_tag.tags %}
- <li><a href="{% pp_url template='tag_detail.html'
object=tag %}">{{tag.name}}</a></li>
- {% endfor %}
- {% endpp_get_tags_for_object %}
-
- {% endif %}
-
- </ul>
-
- {% if request.user.is_authenticated and request.object %}
-
- {% pp_tag_form POST=request.POST path=request.path
object=request.object %}
- <div id="tag_rightcol" style="display:none; overflow:hidden;
height:50px;">
- {{ pp_tag.form.errors }}
- <form method="post" action="">
- {{ pp_tag.form.tag}}
- {{pp_tag.form.form_id}}
- {% csrf_token %}
- <input type="submit" class='button green' value="Submit
Tag">
- </form>
- </div>
- {% endpp_tag_form %}
- {% endif %}
=======================================
--- /trunk/pirate-politics/new_templates/_solution.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/_solution.html Tue Jan 25 15:15:31
2011
@@ -4,7 +4,7 @@
{% load consensustags %}
{% load argumenttags %}
{% load solutiontags %}
-{% load comments %}
+{% load commenttags %}
{% if iss_obj %}
@@ -38,7 +38,6 @@
submitted by<a href="{% pp_url template='user_profile.html'
object=iss_obj.user %}">{{iss_obj.user.username}}</a>
</div>
<div class="col3">
- {% get_comment_count
for iss_obj as comment_count %}
{{comment_count}} comment{{comment_count|pluralize }}
</div>
</div>
=======================================
--- /trunk/pirate-politics/new_templates/_sourcetags.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/_sourcetags.html Tue Jan 25
15:15:31 2011
@@ -6,6 +6,9 @@
{% load solutiontags %}
{% load sourcetags %}
{% load tag_helpers %}
+
+<div class="sourcetags">
+ <div class="sources">
<h2>Sources:
{% ifequal request.user request.object.user %}<a href="javascript:;"
onmousedown="toggleSlide('mydiv');">+url</a>
@@ -18,40 +21,20 @@
<div id="mydiv" style="display:none; overflow:hidden;
height:30px;">
- {% pp_urlsource_form POST=request.POST
object=request.object user=request.user %}
- <div id = "add">
- {{ pp_source.form.errors }}
- <form method="post" action="">
- {{ pp_source.urlform.url}}
- {{ pp_source.urlform.form_id}}
- {% csrf_token %}
- <input type="submit" class="button green"
value="Submit URL">
- </form>
- </div> </div>
- {% endpp_urlsource_form %}
-
-
- </div>
-
- <div id="mydiv2" style="display:none; overflow:hidden;
height:50px;">
-{% comment %}
- {% pp_imgsource_form POST=request.POST FILE=request.FILES
object=request.object %}
- <div id = "add">
- {{ pp_source.imgform.errors }}
- <form form enctype="multipart/form-data" method="post"
action="">
- {{ pp_source.imgform.img}}
- {{ pp_source.imgform.form_id}}
- {% csrf_token %}
- <input type="submit" value="Submit URL">
- </form>
- </div>
- {% endpp_imgsource_form %}
-{% endcomment %}
- </div>
-
-
- {% else %}</div>
- {% endifequal %}
+ {% pp_urlsource_form POST=request.POST
object=request.object user=request.user %}
+ <div id = "add">
+ {{ pp_source.form.errors }}
+ <form method="post" action="">
+ {{ pp_source.urlform.url}}
+ {{ pp_source.urlform.form_id}}
+ {% csrf_token %}
+ <input type="submit" class="button green"
value="Submit URL">
+ </form>
+ </div>
+ {% endpp_urlsource_form %}
+ </div>
+
+ {% endifequal %}
{% pp_get_sources object=request.object %}
<ul>
@@ -69,7 +52,40 @@
{% endpp_get_sources %}
</ul>
-
+</div>
+<div class="tags">
+
+ {% if request.object.taggable %}
+ <ul class="d">
+ <h2><b>Tags:</b> {% if request.user.is_authenticated and
request.object %}<a href="javascript:;"
onmousedown="toggleSlide('tag_rightcol');">+tag</a>{% endif %}</h2>
+ {% pp_get_tags_for_object object=request.object %}
+ {% for tag in pp_tag.tags %}
+ <li><a href="{% pp_url template='tag_detail.html'
object=tag %}">{{tag.name}}</a></li>
+ {% endfor %}
+ {% endpp_get_tags_for_object %}
+
+ {% endif %}
+
+ </ul>
+
+ {% if request.user.is_authenticated and request.object.taggable %}
+
+ {% pp_tag_form POST=request.POST path=request.path
object=request.object %}
+ <div id="tag_rightcol" style="display:none; overflow:hidden;
height:50px;">
+ {{ pp_tag.form.errors }}
+ <form method="post" action="">
+ {{ pp_tag.form.tag}}
+ {{pp_tag.form.form_id}}
+ {% csrf_token %}
+ <input type="submit" class='button green' value="Submit
Tag">
+ </form>
+ </div>
+ {% endpp_tag_form %}
+ {% endif %}
+
+</div>
+</div>
+</div>
=======================================
--- /trunk/pirate-politics/new_templates/argument_detail.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/argument_detail.html Tue Jan 25
15:15:31 2011
@@ -4,7 +4,7 @@
{% load argumenttags %}
{% load consensustags %}
{% load tag_helpers %}
-{% load comments %}
+{% load commenttags %}
{% load markup %}
@@ -31,16 +31,27 @@
{% include '_voting.html' %}
- {% ifequal request.object.user
request.user%}
- <div class="bullet2_">
- <ul><a href="{% pp_url
template='submit_solution.html' object=request.object %}" class='button
blue'>edit</a></ul>
- </div>
- {% endifequal %}
-
-{% get_comment_count for request.object as comment_count %}
+
<div class="issueback2">
+ {% ifequal request.object.user
request.user %}
+ {% ifequal pp_consensus.interest 0 %}
+ {% ifequal
request.object.arg_type.arg "yea" %}
+ <div class="bullet_">
+ <ul><a href="{% pp_url
template='submit_yea_argument.html' object=request.object %}" class='button
blue'>edit</a></ul>
+ </div>
+
+ {% else %}
+ {% ifequal
request.object.arg_type.arg "nay" %}
+ <div class="bullet_">
+ <ul><a href="{% pp_url
template='submit_nay_argument.html' object=request.object %}" class='button
blue'>edit</a></ul>
+ </div>
+ {% endifequal %}
+ {% endifequal %}
+
+ {% endifequal %}
+ {% endifequal %}
{{request.object.name}}<br>
<div class="userinfo">submitted by <a href="{% pp_url
template='user_profile.html'
object=pp_solution.user%}">{{request.object.user.username}}</a>
{{request.object.submit_date|date:"(d/m/Y h:sA)"}} {% comment %}|
{{comment_count}} comment{{comment_count|pluralize}} {% endcomment %}|
interest:{{pp_consensus.consensus.interest|floatformat}}</div>
=======================================
--- /trunk/pirate-politics/new_templates/base.html Fri Jan 21 16:05:49 2011
+++ /trunk/pirate-politics/new_templates/base.html Tue Jan 25 15:15:31 2011
@@ -24,7 +24,13 @@
<script type="text/javascript"
src="/static/jquery-1.4.2.min.js"></script>
+ <script type="text/javascript" src="jCollapsible.min.js"></script>
+
<script type="text/javascript">
+
+ $(document).ready(function(){
+ $('#comments').collapsible({xoffset:'-20',yoffset:'50',
defaulthide: false});
+ });
function changeText(text,div_id)
{
@@ -110,7 +116,7 @@
{% if request.dimension %}
<a STYLE="text-decoration:none" href="{% pp_url
template='issues.html' object=topic dimension=request.dimension%}">{%
ifequal request.object.text topic.text %}<b>{{ topic }}</b>{% else %}{{
topic }}{% endifequal %}</a>
{% else %}
- <a STYLE="text-decoration:none" href="{% pp_url
template='issues.html' object=topic dimension='hot'%}">{{ topic }}</a>
+ <a STYLE="text-decoration:none" href="{% pp_url
template='issues.html' object=topic dimension='hot'%}">{% ifequal
request.object.text topic.text %}<b>{{ topic }}</b>{% else %}{{ topic }}{%
endifequal %}</a>
{% endif %}
{% if not forloop.last %} | {% endif %}
=======================================
--- /trunk/pirate-politics/new_templates/issue_detail.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/issue_detail.html Tue Jan 25
15:15:31 2011
@@ -10,7 +10,7 @@
{% load solutiontags %}
{% load sourcetags %}
{% load tag_helpers %}
-{% load comments %}
+{% load commenttags %}
{% block title %}
{% if request.object %}{{ request.object.text }}{% endif %} Issues
@@ -41,14 +41,21 @@
{% pp_consensus_get object=pp_issue.issue.id
user=request.user %}
<h1> {{ pp_consensus.interest|floatformat }}
</h1>
- {% endpp_consensus_get %}
+
</div>
- {% ifequal pp_issue.issue.user
request.user%}
- <div class="bullet_">
+
+ <div class="issueback">
+ {% ifequal pp_issue.issue.user
request.user %}
+
+ {% ifequal pp_consensus.interest 0 %}
+ {% ifequal
pp_issue.issue.solutions 0 %}
+ <div class="bullet_">
<ul><a href="{% pp_url
template='submit_issue.html' object=pp_issue.issue %}" class='button
blue'>edit</a></ul>
</div>
{% endifequal %}
- <div class="issueback">
+ {% endifequal %}
+ {% endifequal %}
+ {% endpp_consensus_get %}
{{pp_issue.issue.name}}
<div class="threecol">
<div class="colmid">
@@ -60,8 +67,7 @@
<a href="{% pp_url template='solutions.html'
object=pp_issue.issue %}">see {{ pp_issue.issue.solutions}}
solution{{pp_issue.issue.solutions|pluralize}}...</a>
</div>
<div class="col3">
- {% get_comment_count
for pp_issue.issue as comment_count %}
- {{comment_count}} comment{{comment_count|pluralize }}
+ 0 comments
</div>
</div>
</div>
@@ -71,9 +77,23 @@
<div class="details">
{{pp_issue.issue.text|markdown}}
-
- {% include "_sourcetags.html" %}
</div>
+
+ {% include "_sourcetags.html" %}
+
+ {% include '_commentform.html' %}
+
+ {% pp_load_comments object=pp_issue.issue %}
+
+ {% for node, count in pp_comment.nodes %}
+
+ {% include '_commentleaf.html' %}
+
+ {% endfor %}
+
+ {% endpp_load_comments%}
+
+
{% endpp_get_issue %}
</div>
<div class="rightcol">
=======================================
--- /trunk/pirate-politics/new_templates/issues.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/issues.html Tue Jan 25 15:15:31
2011
@@ -6,7 +6,6 @@
{% load consensustags %}
{% load argumenttags %}
{% load solutiontags %}
-{% load comments %}
{% block title %}
{% if request.object %}{{ request.object.text }}{% endif %} Issues
=======================================
--- /trunk/pirate-politics/new_templates/register.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/register.html Tue Jan 25 15:15:31
2011
@@ -10,12 +10,13 @@
{% block content%}
{% pp_user_registration_form POST=request.POST path=request.path
request=request %}
-
+<div class="register_title">
+<h2>Welcome to elgalit.ar</h2>
+</div>
<div class = "register">
-
-
+ <div class="register_registration">
+ <h3> Register a new account!</h3>
<form method="post" action="">
- <h2>Welcome to elgalit.ar</h2>
Username:<br>
{{ pp_login.form.name }}<br>
Password:<br>
@@ -30,6 +31,23 @@
<div class="error">{{pp_login.errors}}<br>{{ pp_login.form.errors
}}</div>
</form>
</div>
+ <div class="register_login">
+ <h3> Login to existing account!</h3>
+ {% pp_user_login_form POST=request.POST path=request.path
request=request %}
+ {{ pp_login.form.errors }}
+ <form method="post" action="">
+ Username:
+ <br> {{ pp_login.form.name }}<br>
+ Password:<br> {{ pp_login.form.password }}<br><br>
+ {{ pp_login.form.form_id}}
+ {% csrf_token %}
+ <input type="submit" class="button green" value="Login">
+ </form>
+ {% endpp_user_login_form %}
+ </div>
+
+ </div>
+
{% endpp_user_registration_form %}
{% endblock content %}
=======================================
--- /trunk/pirate-politics/new_templates/solution_detail.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/solution_detail.html Tue Jan 25
15:15:31 2011
@@ -10,7 +10,7 @@
{% load solutiontags %}
{% load sourcetags %}
{% load tag_helpers %}
-{% load comments %}
+{% load commenttags %}
{% block title %}
{% if request.object %}{{ request.object.text }}{% endif %} Issues
@@ -48,19 +48,19 @@
{% include '_voting.html' %}
- {% ifequal pp_solution.solution.user
request.user%}
- <div class="bullet2_">
+ <div class="issueback2">
+ {% ifequal pp_solution.solution.user
request.user %}
+ {% ifequal pp_consensus.interest 0 %}
+ {% ifequal
pp_solution.solution.arguments 0 %}
+ <div class="bullet_">
<ul><a href="{% pp_url
template='submit_solution.html' object=pp_solution.solution %}"
class='button blue'>edit</a></ul>
</div>
{% endifequal %}
-
-{% get_comment_count for request.object as comment_count %}
-
-
- <div class="issueback2">
+ {% endifequal %}
+ {% endifequal %}
{{pp_solution.solution.name}}<br>
-<div class="userinfo">submitted by <a href="{% pp_url
template='user_profile.html'
object=pp_solution.user%}">{{pp_solution.solution.user.username}}</a>
{{pp_solution.solution.submit_date|date:"(d/m/Y h:sA)"}} {% comment %}|
{{comment_count}} comment{{comment_count|pluralize}} {% endcomment %}|
interest:{{pp_consensus.consensus.interest|floatformat}}</div>
+<div class="userinfo">submitted by <a href="{% pp_url
template='user_profile.html'
object=pp_solution.solution.user%}">{{pp_solution.solution.user.username}}</a>
{{pp_solution.solution.submit_date|date:"(d/m/Y h:sA)"}} {% comment %}|
{{comment_count}} comment{{comment_count|pluralize}} {% endcomment %}|
interest:{{pp_consensus.consensus.interest|floatformat}}</div>
</div>
=======================================
--- /trunk/pirate-politics/new_templates/solutions.html Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/new_templates/solutions.html Tue Jan 25 15:15:31
2011
@@ -6,7 +6,7 @@
{% load consensustags %}
{% load argumenttags %}
{% load solutiontags %}
-{% load comments %}
+{% load commenttags %}
{% block css %}
<link rel="stylesheet" type="text/css" href="/static/style.css" />
=======================================
--- /trunk/pirate-politics/new_templates/submit_issue.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/submit_issue.html Tue Jan 25
15:15:31 2011
@@ -13,9 +13,9 @@
<div class="issuemask">
<div class="submissionbound">
{% if request.object %}
-{% pp_issue_form POST=request.POST path=request.path request=request
topic=request.object %}
+{% pp_issue_form POST=request.POST path=request.path request=request
object=request.object %}
<div class="add">
- <h2>Create Issue with topic {{request.object.text }}</h2>
+ <h2> {{pp_issue.contextname }}</h2>
{{ pp_issue.form.errors }}
<form method="post" action="">
Name: <br>{{ pp_issue.form.name }}<br>
@@ -29,7 +29,7 @@
{% else %}
{% pp_issue_form POST=request.POST path=request.path request=request %}
<div class="add">
- <h2>Submit a New Issue</h2>
+ <h2>{{pp_issue.contextname }}</h2>
{{ pp_issue.form.errors }}
<form method="post" action="">
Name: <br>{{ pp_issue.form.name }}<br>
=======================================
--- /trunk/pirate-politics/new_templates/submit_solution.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/submit_solution.html Tue Jan 25
15:15:31 2011
@@ -12,7 +12,7 @@
<div class="stage">
<div class="issuemask">
<div class="submissionbound">
-{% pp_solution_form POST=request.POST path=request.path
issue=request.object request=request %}
+{% pp_solution_form POST=request.POST path=request.path
object=request.object request=request %}
<div class="add">
<h2>Submit a new solution for: <br>{{request.object.name}}</h2>
{{ pp_solution.form.errors }}
=======================================
--- /trunk/pirate-politics/new_templates/tag_detail.html Tue Jan 18
11:59:15 2011
+++ /trunk/pirate-politics/new_templates/tag_detail.html Tue Jan 25
15:15:31 2011
@@ -12,12 +12,6 @@
{% block content %}
<div class="stage">
<div class="issuemask">
-
- <div class="rightcol">
-
- {% include "_rightcol.html" %}
-
- </div>
<div class="issuebound">
<h1>Objects for {{request.object.name}}</h1>
@@ -49,6 +43,13 @@
</ul>
{% endpp_get_objects_for_tag %}
</div>
+
+
+ <div class="rightcol">
+
+ {% include "_rightcol.html" %}
+
+ </div>
</div>
</div>
</div>
=======================================
--- /trunk/pirate-politics/new_templates/user_profile.html Fri Jan 21
16:05:49 2011
+++ /trunk/pirate-politics/new_templates/user_profile.html Tue Jan 25
15:15:31 2011
@@ -36,7 +36,8 @@
{% ifequal request.user request.object %}
{% if request.user.is_authenticated %}
{% pp_profile_form POST=request.POST
user=request.user %}
- <h2>Add profile for {{request.user.username}}</h2>
+ <h2><a href="javascript:;"
onmousedown="toggleSlide('add_profile');">Add profile for
{{request.user.username}}</a></h2>
+ <div id="add_profile" style="display:none;
overflow:hidden; height:250px;">
<div id = "add">
{{ pp_profile.form.errors }}
<form method="post" action="">
@@ -49,7 +50,7 @@
{% csrf_token %}
<input type="submit" class="button green"
value="Submit">
</form>
- </div>
+ </div></div>
{% endpp_profile_form %}
{% endif %}
{% endifequal %}
@@ -57,6 +58,9 @@
{% if request.user.is_staff %}
<hr>
+
+
+
<h3> Staff Control Panel </h3>
{% pp_topic_form POST=request.POST path=request.path %}
<b>Add Topic (Use at discretion) </b><br>
=======================================
--- /trunk/pirate-politics/pirate_consensus/models.py Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/pirate_consensus/models.py Tue Jan 25 15:15:31
2011
@@ -19,6 +19,7 @@
votes = models.IntegerField(default = 0)
interest = models.FloatField(default=0.0)
controversy = models.FloatField(default=0.0)
+ is_edittable = models.BooleanField(default=True) #refers to edittable
property of parent, nullified by a vote
def __unicode__(self):
return str(self.content_type) + ':' + str(self.object_pk)
=======================================
--- /trunk/pirate-politics/pirate_core/middleware.py Fri Jan 21 16:05:49
2011
+++ /trunk/pirate-politics/pirate_core/middleware.py Tue Jan 25 15:15:31
2011
@@ -36,7 +36,7 @@
request_path = request.get_full_path()
name = request_path
- if request_path != '/favicon.ico' and
request_path[0:7] != '/submit' and request_path != '/vote/':
+ if request_path != '/favicon.ico' and
request_path[0:7] != '/submit' and request_path != '/vote/' and
request_path != '/jCollapsible.min.js':
try:
if request.session['currently_visiting'] != request_path:
try:
@@ -73,7 +73,7 @@
request.session['last_visited'] = visit_list
except KeyError: pass
- if request_path != '/favicon.ico' and
request_path[:8] != '/submit' and request_path != '/vote/':
+ if request_path != '/favicon.ico' and
request_path[:8] != '/submit' and request_path != '/vote/' and
request_path != '/jCollapsible.min.js':
request.session['currently_visiting'] = request_path
class AddToBuiltinsMiddleware(object):
=======================================
--- /trunk/pirate-politics/pirate_core/views.py Thu Jan 13 13:59:30 2011
+++ /trunk/pirate-politics/pirate_core/views.py Tue Jan 25 15:15:31 2011
@@ -18,7 +18,7 @@
"""
template_dict = {u'issue':'issue_detail.html',
u'solution':'solution_detail.html',
-
u'argument':'argument_detail.html',u'profile':'user_profile.html'}
+
u'argument':'argument_detail.html',u'profile':'user_profile.html',u'topic':u'issues.html'}
try:
ret = template_dict[model]
return ret
=======================================
--- /trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
Fri Jan 21 16:05:49 2011
+++ /trunk/pirate-politics/pirate_deliberation/templatetags/argumenttags.py
Tue Jan 25 15:15:31 2011
@@ -103,43 +103,45 @@
POST = kwargs.get('POST', None)
path = kwargs.get('path', "")
- solution = kwargs.get('object', None)
- arg = kwargs.get('arg', None)
+ obj = kwargs.get('object', None)
arg_type = kwargs.get('arg_type', None)
request = kwargs.get('request',None)
- #generate path to argument
- load = "{% load pp_url %}"
- ts = "{% pp_url template='solution_detail.html' object=solution %}"
- path = template.Template(load +
ts).render(template.Context({'solution':solution}))
-
if isinstance(arg_type, unicode):
arg_type, created = Stance.objects.get_or_create(arg=arg_type)
-
+
+ if isinstance(obj, Solution):
+ solution = obj
+ arg = None
+ elif isinstance(obj, Argument):
+ arg = obj
+ solution = arg.parent
+ else: arg, solution = (None, None)
+
if POST and POST.get("form_id") == "pp_argument_form":
form = ArgumentForm(POST) if arg is None else ArgumentForm(POST,
instance=arg)
new_arg = form.save(commit=False)
- if arg == None:
- new_arg.pub_date = datetime.datetime.now()
- new_arg.parent = solution
- new_arg.user = request.user
- new_arg.arg_type = arg_type
- new_arg.save()
- contype = ContentType.objects.get_for_model(Argument)
- obj_pk = new_arg.pk
- cons, is_new =
Consensus.objects.get_or_create(content_type=contype,
-
object_pk=obj_pk)
-
- if is_new: #if this is a new issue/consensus, send signal for
reputation
- aso_rep_event.send(sender=new_arg,event_score=4,
user=new_arg.user,
dimension=ReputationDimension.objects.get('add_argument'))
- new_arg.parent.arguments += 1
- new_arg.parent.issue.arguments +=1
- new_arg.parent.issue.save()
- new_arg.parent.save()
-
- raise HttpRedirectException(HttpResponseRedirect(path))
+ new_arg.pub_date = datetime.datetime.now()
+ new_arg.parent = solution
+ new_arg.user = request.user
+ new_arg.arg_type = arg_type
+ new_arg.save()
+ contype = ContentType.objects.get_for_model(Argument)
+ obj_pk = new_arg.pk
+ cons, is_new =
Consensus.objects.get_or_create(content_type=contype,
+ object_pk=obj_pk)
+
+ if is_new: #if this is a new issue/consensus, send signal for
reputation
+ aso_rep_event.send(sender=new_arg,event_score=4,
user=new_arg.user,
dimension=ReputationDimension.objects.get('add_argument'))
+ new_arg.parent.arguments += 1
+ new_arg.parent.issue.arguments +=1
+ new_arg.parent.issue.save()
+ new_arg.parent.save()
+
+ raise
HttpRedirectException(HttpResponseRedirect(new_arg.get_absolute_url()))
else:
form = ArgumentForm() if arg is None else
ArgumentForm(instance=arg)
+
namespace['form'] = form
output = nodelist.render(context)
=======================================
--- /trunk/pirate-politics/pirate_issues/templatetags/issuetags.py Fri Jan
21 16:05:49 2011
+++ /trunk/pirate-politics/pirate_issues/templatetags/issuetags.py Tue Jan
25 15:15:31 2011
@@ -252,8 +252,7 @@
POST = kwargs.get('POST', None)
path = kwargs.get('path', None)
- issue = kwargs.get('issue', None)
- topic = kwargs.get('topic', None)
+ obj = kwargs.get('object',None)
request = kwargs.get('request',None)
#question: issue_consensus doesn't seem to be used. Is there a future
need for it?
@@ -264,8 +263,15 @@
# is going to know how to set the default choice to be the same
# as the passed-in argument
- if isinstance(topic, Topic) and isinstance(issue, Issue):
- issue.topic = topic
+ if isinstance(obj, Issue):
+ topic = obj.topic
+ issue = obj
+ namespace['contextname'] = "Edit issue " + str(issue.name)
+ elif isinstance(obj,Topic):
+ topic = obj
+ issue = None
+ namespace['contextname'] = "Create issue on " + str(topic.text)
+ else: issue, topic = (None, None)
if POST and POST.get("form_id") == "pp_issue_form":
form = IssueForm(POST) if issue is None else IssueForm(POST,
instance=issue)
issue = form.save(commit=False)
=======================================
--- /trunk/pirate-politics/pirate_issues/templatetags/solutiontags.py Sat
Jan 22 12:29:38 2011
+++ /trunk/pirate-politics/pirate_issues/templatetags/solutiontags.py Tue
Jan 25 15:15:31 2011
@@ -143,21 +143,21 @@
POST = kwargs.get('POST', None)
path = kwargs.get('path', None)
- solution = kwargs.get('solution', None)
- issue = kwargs.get('issue', None)
+ obj = kwargs.get('object',None)
user = kwargs.get('user',None)
request = kwargs.get('request',None)
#generate path to this solution
-
-
- #question: issue_consensus doesn't seem to be used. Is there a future
need for it?
- #issue_consensus = kwargs.get('consensus', None)
+
#print POST
#print request
-
-
+ if obj and isinstance(obj, Issue):
+ issue = obj
+ solution = None
+ elif obj and isinstance(obj,Solution):
+ solution = obj
+ issue = solution.issue
if POST and POST.get("form_id") == "pp_solution_form":
form = SolutionForm(POST) if solution is None else
SolutionForm(POST, instance=solution)
if form.is_valid():
=======================================
--- /trunk/pirate-politics/pirate_issues/templatetags/usertags.py Fri Jan
21 16:05:49 2011
+++ /trunk/pirate-politics/pirate_issues/templatetags/usertags.py Tue Jan
25 15:15:31 2011
@@ -12,6 +12,7 @@
from pirate_reputation.models import ReputationDimension
from django.contrib.auth import authenticate, login
from django.core.validators import validate_email
+from pirate_core.views import template_for_model
from pirate_signals.models import aso_rep_event
from pirate_login.models import Login, Register
@@ -109,6 +110,7 @@
POST = kwargs.get('POST', None)
path = kwargs.get('path', "")
request = kwargs.get('request',None)
+ obj = kwargs.get('object', None)
if POST and POST.get("form_id") == "pp_user_login_form":
try:
@@ -118,7 +120,17 @@
if user is not None:
if user.is_active:
login(request, user)
- raise HttpRedirectException(HttpResponseRedirect(path))
+ if obj:
+ content_type = ContentType.objects.get_for_model(obj)
+ temp = template_for_model(str(content_type))
+ path2 = temp + "?_t=" + str(content_type.pk) + "&_o=" +
str(obj.pk)
+ if path != temp: path2 = path + "?_t=" +
str(content_type.pk) + "&_o=" + str(obj.pk)
+ else: path2 = temp + "?_t=" + str(content_type.pk)
+ "&_o=" + str(obj.pk)
+
+ raise HttpRedirectException(HttpResponseRedirect(path2))
+
+ else:
+ raise
HttpRedirectException(HttpResponseRedirect('/issues.html'))
except HttpRedirectException, e:
raise e
else:
=======================================
--- /trunk/pirate-politics/pirate_login/views.py Mon Jan 17 10:25:31 2011
+++ /trunk/pirate-politics/pirate_login/views.py Tue Jan 25 15:15:31 2011
@@ -1,7 +1,10 @@
# Create your views here.
from django.contrib.auth import logout
from django.http import HttpResponseRedirect
+from pirate_core import HttpRedirectException, namespace_get, FormMixin
def logout_view(request):
- logout(request)
- return HttpResponseRedirect('/issues.html')
+ try: goto = request.session['last_visited'][0][1]
+ except: goto = '/issues.html'
+ logout(request)
+ return HttpResponseRedirect(goto)
=======================================
--- /trunk/pirate-politics/settings.py Tue Jan 18 11:59:15 2011
+++ /trunk/pirate-politics/settings.py Tue Jan 25 15:15:31 2011
@@ -13,7 +13,6 @@
'django.contrib.sessions',
'django.contrib.admin',
'django.contrib.markup',
- 'django.contrib.comments',
'customtags',
'tagging',
'hello',
@@ -28,6 +27,7 @@
'pirate_login',
'pirate_profile',
'pirate_sources',
+ 'pirate_comments',
)
=======================================
--- /trunk/pirate-politics/static/style.css Fri Jan 21 16:05:49 2011
+++ /trunk/pirate-politics/static/style.css Tue Jan 25 15:15:31 2011
@@ -74,11 +74,36 @@
background-position: 0 center;
color:#FFFFF;
}
+
+
+
+.register_title {
+ float:center;
+ left:36%;
+ position:relative;
+}
.register {
float:center;
+ left:21%;
position:relative;
- left:40%;
+}
+
+.register .register_registration {
+ border-right: 5px solid #ccc;
+ position:relative;
+ width:25%;
+
+ float:left;
+
+}
+
+.register .register_login {
+ position:relative;
+ width:25%;
+ float:left;
+ left:10%;
+
}
.error {
@@ -261,7 +286,6 @@
position:relative;
width:100%;
color:black;
- /*background: url('Bullet.png') no-repeat scroll;*/
/*background-color:#d3d9df;*/
/*overflow:hidden;*/
/*border:1px dashed black;*/
@@ -350,14 +374,16 @@
-moz-border-radius:5px;
}
.bullet:after {
+ color:white;
content:"interest";
position: relative;
- left: 11px;
+ left: 10%;
top: -30px;
font-size: small;
}
.bullet h1, .bullet p {
+ color:white;
padding:8px;
text-align:center;
border:0;
@@ -385,10 +411,8 @@
.bullet_ {
font-size:75%;
position:absolute;
- top:+40px;
- left:-90px;
+ right:1%;
padding:0px 0px 0px 0px;
- margin:30px 10px 0px 0px;
}
.bullet2_ {
@@ -410,7 +434,7 @@
.add_tag {
font-size:20%;
- }
+}
.threecol {
position:relative; /* This fixes the IE7 overflow hidden bug */
@@ -435,6 +459,26 @@
position:relative;
overflow:hidden;
}
+.sourcetags {
+ position:relative;
+ overflow:hidden;
+}
+
+
+.sourcetags .sources {
+ position:relative;
+ width:50%;
+ float:left;
+ overflow:hidden;
+}
+
+.sourcetags .tags {
+ position:relative;
+ width:50%;
+ float:right;
+ overflow:hidden;
+}
+
.colmid,
.colleft {
float:left;
@@ -556,3 +600,9 @@
.button.small:active { padding: 4px 7px 2px; background-position: 0 top; }
.button.large { font-size: 125%; padding: 7px 12px; }
.button.large:active { padding: 8px 12px 6px; background-position: 0 top; }
+
+#comments { padding: 0; margin: 0; }
+#comments li { float: left; padding: 10px 0 0; }
+.comment { background: #fff; padding: 10px; display: block; overflow:
hidden; }
+.comment-author { float: left; width: 50px; font-size: 10px; text-align:
center; margin: 0 10px 10px 0; }
+.comment-body, .comment-body p { font-size: 12px; line-height: 18px;
margin: 0; }