Commits

Vladimir Korsun committed 1f38981 Draft

Translation, delete comfirmation and other improves.

Comments (0)

Files changed (11)

+from django.contrib import admin
+from dnews.models import News
+
+class NewsAdmin(admin.ModelAdmin):
+    list_display = ('title', 'author', 'created', 'changed')
+
+admin.site.register(News, NewsAdmin)

dnews/locale/ru/LC_MESSAGES/django.mo

Binary file added.

dnews/locale/ru/LC_MESSAGES/django.po

+# 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 <EMAIL@ADDRESS>, YEAR.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: PACKAGE VERSION\n"
+"Report-Msgid-Bugs-To: \n"
+"POT-Creation-Date: 2012-06-22 20:48+0400\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\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%10==1 && n%100!=11 ? 0 : n%10>=2 && n"
+"%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n"
+
+#: models.py:18 models.py:19 templates/dnews/news_list.html:4
+#: templates/dnews/news_list.html.py:7
+msgid "News"
+msgstr "Новости"
+
+#: templates/dnews/last_news.html:8
+msgid "No one news found."
+msgstr "Ни одна новость не найдена."
+
+#: templates/dnews/news_confirm_delete.html:5
+#, python-format
+msgid "Want to delete news «%(object)s»?"
+msgstr "Хотите удалить новость «%(object)s»?"
+
+#: templates/dnews/news_confirm_delete.html:8
+msgid "Confirm"
+msgstr "Подтвердить"
+
+#: templates/dnews/news_detail.html:11
+msgid "Created"
+msgstr "Создано"
+
+#: templates/dnews/news_detail.html:15
+msgid "Author"
+msgstr "Автор"
+
+#: templates/dnews/news_detail.html:20
+msgid "Source"
+msgstr "Источник"
+
+#: templates/dnews/news_detail.html:27
+msgid "Update this news"
+msgstr "Редактировать новость"
+
+#: templates/dnews/news_form.html:4 templates/dnews/news_form.html.py:7
+msgid "Create news entry"
+msgstr "Добавить новость"
+
+#: templates/dnews/news_list.html:9
+msgid "Create news"
+msgstr "Добавить новость"
 from django.db import models
 from django.contrib.auth.models import User
+from django.utils.translation import ugettext as _
 
 from markdown import markdown
 
 class News(models.Model):
     author = models.ForeignKey(User)
     title = models.CharField(max_length=80)
-    source = models.URLField(verify_exists=True, blank=True)
-    body = models.TextField()
+    source = models.URLField(verify_exists=False, blank=True)
+    body = models.TextField(blank=True)# TODO: blank=False
     body_html = models.TextField()
     created = models.DateTimeField(auto_now_add=True)
     changed = models.DateTimeField(auto_now=True)
 
     class Meta:
+        verbose_name = _('News')
+        verbose_name_plural = _('News')
         ordering = ['-created', ]
 
     def __unicode__(self):
 
     @models.permalink
     def get_absolute_url(self):
-        return 'news:detail', [str(self.id), ]
+        return 'news:detail', [str(self.pk), ]
 
-    def save(self, force_insert=False, force_update=False):
+    def save(self, *args, **kwargs):
         self.body_html = markdown(self.body, output_format="XHTML",
             safe_mode="remove")
-        super(News, self).save(force_insert, force_update)
+        super(News, self).save(*args, **kwargs)

dnews/templates/dnews/last_news.html

             <a href="{% url news:detail object.pk %}">{{ object }}</a>
         </li>
     {% empty %}
-        <li>{% trans "No news found." %}</li>
+        <li>{% trans "No one news found." %}</li>
     {% endfor %}
-</ul>
+</ul>

dnews/templates/dnews/news_confirm_delete.html

+{% extends "base.html" %}
+{% load i18n %}
+
+{% block content %}
+    <h1>{% blocktrans %}Want to delete news «{{ object }}»?{% endblocktrans %}</h1>
+    <form action="." method="post">
+        {% csrf_token %}
+        <p><input type="submit" value="{% trans "Confirm" %}" /></p>
+    </form>
+{% endblock %}

dnews/templates/dnews/news_detail.html

 {% extends "base.html" %}
 {% load i18n thumbnail %}
 
-{% block title %}{{object}} - {{block.super}}{% endblock %}
+{% block title %}{{ object }} - {{ block.super }}{% endblock %}
 
 {% block content %}
-<h1>{{object}}</h1>
-{{object.body_html|safe}}
-<table class="meta">
-<tr><th>{% trans "Created" %}:</th><td>{{object.created|date:"SHORT_DATE_FORMAT"}}</td></tr>
-<tr><th>{% trans "Author" %}:</th><td>{{object.author}}</td></tr>
-{% if object.source %}
-<tr><th>{% trans "Source" %}:</th><td><a href="{{object.source}}">{{object.source}}</a></td></tr>
-{% endif %}
-</table>
-{% if perms.news.can_edit %}
-<p><a href="{% url news:update object.id %}">{% trans "Update this news" %}</a></p>
-{% endif %}
+    <h1>{{ object }}</h1>
+    {{ object.body_html|safe }}
+    <table class="meta">
+        <tr>
+            <th>{% trans "Created" %}:</th>
+            <td>{{ object.created|date:"SHORT_DATE_FORMAT" }}</td>
+        </tr>
+        <tr>
+            <th>{% trans "Author" %}:</th>
+            <td>{{ object.author }}</td>
+        </tr>
+        {% if object.source %}
+            <tr>
+                <th>{% trans "Source" %}:</th>
+                <td><a href="{{object.source}}">{{ object.source }}</a></td>
+            </tr>
+        {% endif %}
+    </table>
+    {% if perms.news.can_edit %}
+        <p>
+            <a href="{% url news:update object.id %}">{% trans "Update this news" %}</a>
+        </p>
+    {% endif %}
 {% endblock %}

dnews/templates/dnews/news_form.html

 {% extends "base.html" %}
 {% load i18n thumbnail %}
 
-{% block title %}{% trans "Create news entry" %} - {{block.super}}{% endblock %}
+{% block title %}{% trans "Create news entry" %} - {{ block.super }}{% endblock %}
 
 {% block content %}
-<h1>{% trans "Create news entry" %}</h1>
-<form action="." method="post">
-{% include "form.html" %}
-</form>
+    <h1>{% trans "Create news entry" %}</h1>
+    <form action="." method="post">
+        {% include "form.html" %}
+    </form>
 {% endblock %}
 

dnews/templates/dnews/news_list.html

 {% extends "base.html" %}
 {% load i18n thumbnail %}
 
-{% block title %}{% trans "News" %} - {{block.super}}{% endblock %}
+{% block title %}{% trans "News" %} - {{ block.super }}{% endblock %}
 
 {% block content %}
-<h1>{% trans "News" %}</h1>
-{% if perms.news.can_create %}
-<a href="{% url news:create %}">{% trans "Create news" %}</a>
-{% endif %}
-<ul class="news">
-{% for object in object_list %}
-<li><h2><a href="{% url news:detail object.id %}">{{object}}</a>
-<span class="published">{{object.created|date:"SHORT_DATE_FORMAT"}}</span></h2>
-{{object.body_html|safe|truncatewords_html:50}}</li>
-{% endfor %}
-</ul>
-{% include "paginator.html" %}
+    <h1>{% trans "News" %}</h1>
+    {% if perms.news.can_create %}
+        <a href="{% url news:create %}">{% trans "Create news" %}</a>
+    {% endif %}
+    <ul class="news">
+        {% for object in object_list %}
+            <li><h2><a href="{% url news:detail object.id %}">{{ object }}</a>
+                <span class="published">{{ object.created|date:"SHORT_DATE_FORMAT" }}</span>
+            </h2>
+                {{ object.body_html|safe|truncatewords_html:50 }}</li>
+        {% endfor %}
+    </ul>
+    {% include "paginator.html" %}
 {% endblock %}
 
     url(r'^create/$', NewsCreate.as_view(), name='create'),
     url(r'^(?P<pk>\d+)/$', NewsDetail.as_view(), name='detail'),
     url(r'^(?P<pk>\d+)/update/$', NewsUpdate.as_view(), name='update'),
+    url(r'^(?P<pk>\d+)/delete/$', NewsDelete.as_view(), name='delete'),
 )
 from distutils.core import setup
 
 setup(
-name = 'dnews',
-version = '1.0',
-packages = ['dnews'],
-package_dir={'dnews': 'dnews'},
-package_data = {'dnews': [
-#    'templatetags/*',
-#    'urls/*',
-    'templates/*/*',
-#    'fixtures/*',
-#    'locale/*/*',
-#    'migrations/*',
-    ]},
+    name='dnews',
+    version='1.0',
+    packages=['dnews'],
+    package_dir={'dnews': 'dnews'},
+    package_data={'dnews': [
+        'templatetags/*',
+        'templates/*/*',
+    ]}, requires=['django', "markdown"],
 )