Commits

angri  committed 937c9ae

коменты немного причесаны, но пока еще остаются проблемы с неоднозначностью idea.get_absolute_url

  • Participants
  • Parent commits bfe012d

Comments (0)

Files changed (9)

File brainstill/models.py

 
     @models.permalink
     def get_absolute_url(self):
-        return ('brainstill_project_detail', (),
+        return ('brainstill_idea_detail', (),
                 {'project_slug': self.project.slug, 'idea_id': self.pk})
 
     def __unicode__(self):

File brainstill/urls.py

     url(r'%s/#(?P<idea_id>\d+)$' % _project_slug_prefix,
         views.project_detail,
         dict(template_name='brainstill/project_detail.html'),
-        name='brainstill_project_detail'),
+        name='brainstill_idea_detail'),
 
     url(r'%s/idea-new/$' % _project_slug_prefix,
         views.idea_new,

File bsproj/custom_comments/forms.py

+from django import forms
+from django.utils.translation import ugettext as _
+
 from django.contrib.comments.forms import CommentForm
 
 
 class SimpleCommentForm(CommentForm):
+    def clean_comment(self):
+        value = super(SimpleCommentForm, self).clean_comment().strip()
+        if not value:
+            raise forms.ValidationError(
+                self.fields['comment'].default_error_messages['required']
+            )
+        return value
     def clean(self):
         cleaned_data = self.cleaned_data
         cleaned_data['name'] = cleaned_data['email'] = cleaned_data['url'] = ''

File bsproj/templates/brainstill/idea_detail.html

 
   {% render_comment_list for idea %}
 
-  {% render_comment_form for idea %}
+  {% with idea.get_absolute_url as next %}
+    {% render_comment_form for idea %}
+  {% endwith %}
 {% endwith %}
 {% endblock %}

File bsproj/templates/brainstill/project_detail.html

       <a name="{{ idea.pk }}"></a>
       <h2>
         <span class="idea-number">#{{ idea.pk }} </span>
-        <span class="idea-title"><a href="{% url idea_detail idea.pk %}">{{ idea }}</a></span>
+        <span class="idea-title"><a href="{% url brainstill_idea_detail idea.pk %}">{{ idea }}</a></span>
         {% ranks_and_votes idea %}
       </h2>
       <p class="info">

File bsproj/templates/comments/form.html

 {% load comments i18n %}
-<form action="{% comment_form_target %}" method="post">{% csrf_token %}
+<form action="{% comment_form_target %}" method="post" class="comment">{% csrf_token %}
   {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
   {% for field in form %}
     {% if field.is_hidden %}

File bsproj/templates/comments/preview.html

+{% extends "layout0.html" %}
+{% load i18n comments %}
+
+
+{% block content %}
+  <h1>{% blocktrans with form.target_object.get_absolute_url as url and form.target_object as target %}
+    Post a comment for <a href="{{ url }}">{{ target }}</a>
+  {% endblocktrans %}
+  </h1>
+
+  {% with form.target_object.get_absolute_url as next %}
+    {% include "comments/form.html" %}
+  {% endwith %}
+{% endblock %}

File bsproj/urls.py

 
     url(r'^comments/', include('django.contrib.comments.urls')),
 
+    url(r'^projects/', include('brainstill.urls')),
     url(r'^idea(?P<object_id>\d+)/$', list_detail.object_detail,
         dict(queryset=Idea.objects.all()),
-        name='idea_detail'),
-    url(r'', include('brainstill.urls')),
+        name='brainstill_idea_detail'),
 
     url(r'^%s(?P<path>.*)$' % media_url, 'django.views.static.serve',
         {'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),

File media/style.css

   text-align: right;
 }
 form dd { width: 400px; }
-form dd .errorlist li {
+form .errorlist {
   color: #ef2929;
   font-size: 75%;
 }
 
-form.new-idea input, form.new-idea textarea { width: 450px; }
+form.new-idea input, form.new-idea textarea, form.comment textarea { width: 450px; }