Commit bbfb2e3e authored by Stéphane Raimbault's avatar Stéphane Raimbault Committed by Stéphane Raimbault

New settings for email and upload. Link to Vertimus view. Vertimus

2008-12-24  Stéphane Raimbault  <stephane.raimbault@gmail.com>

	* settings_sample.py: New settings for email and upload.
	* templates/stats_show.html: Link to Vertimus view.
	* templates/vertimus/vertimus_detail.html: Vertimus template
	* urls.py: Forward to vertimus.urls
	* vertimus/models.py: Major model changes.
	* vertimus/tests/__init__.py: 20 unit tests.
	* vertimus/urls.py: Vertimus URLs.
	* vertimus/views.py: View and form management.
	* media/img/person.png: Nice person icon.

svn path=/trunk/; revision=1239
parent 098a7c62
2008-12-24 Stéphane Raimbault <stephane.raimbault@gmail.com>
* settings_sample.py: New settings for email and upload.
* templates/stats_show.html: Link to Vertimus view.
* templates/vertimus/vertimus_detail.html: Vertimus template
* urls.py: Forward to vertimus.urls
* vertimus/models.py: Major model changes.
* vertimus/tests/__init__.py: 20 unit tests.
* vertimus/urls.py: Vertimus URLs.
* vertimus/views.py: View and form management.
* media/img/person.png: Nice person icon.
2008-12-24 Stéphane Raimbault <stephane.raimbault@gmail.com>
* people/models.py: Fallback to username if no first_name or last_name
......
......@@ -38,6 +38,12 @@ DATABASE_PORT = '' # Set to empty string for default. Not used with
#
# Please refer to the README file to create an UTF-8 database with MySQL.
EMAIL_HOST = 'localhost'
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_SUBJECT_PREFIX = '[DL]'
SERVER_EMAIL = 'server@l10n.gnome.org'
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
......@@ -64,6 +70,11 @@ MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = 'media'
# By default, Django stores files locally, using the MEDIA_ROOT and MEDIA_URL settings
UPLOAD_DIR = 'upload'
UPLOAD_BACKUP_DIR = 'upload-backup'
FILE_UPLOAD_PERMISSIONS = 0600
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
......@@ -86,6 +97,7 @@ MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.transaction.TransactionMiddleware',
)
ROOT_URLCONF = 'djamnedlies.urls'
......
......@@ -5,57 +5,61 @@
<h3>{% trans stat1.domain.get_description %}
{% ifnotequal stat1.domain.directory 'help' %}
{% ifnotequal stat1.domain.directory 'po' %}
<br /><span class='path'>{{ stat1.domain.directory }}</span>
<br />
<span class="path">{{ stat1.domain.directory }}</span>
{% endifnotequal %}
{% endifnotequal %}</h3>
{% endifnotequal %}
</h3>
<a href="{{ stat1.po_url }}"><img src="/media/img/download.png" alt="Download POT file" /></a>
{{ stat1.pot_text }}
<!-- /* This is the title of the section that lists notices about a module */ -->
<!-- This is the title of the section that lists notices about a module -->
{% if stat1.information_set.all %}
<h4>{% trans "Notices" %}</h4>
<table>
<h4>{% trans "Notices" %}</h4>
<table>
{% for msg in stat1.information_set.all %}
<tr><td valign="top"><img src="{{ msg.get_icon }}" alt="{{ msg.type }}" /></td><td>{{ msg.get_description|safe }}</td></tr>
<tr>
<td valign="top"><img src="{{ msg.get_icon }}" alt="{{ msg.type }}" /></td>
<td>{{ msg.get_description|safe }}</td>
</tr>
{% endfor %}
</table>
</table>
{% endif %}
<table class="stats">
<thead><tr><th>{% trans "Language" %}</th><th>{% trans "Translated" %}</th>
{% if stat1.fig_count %}
<th></th>
{% endif %}
<th>{% trans "Graph" %}</th></tr></thead>
<table class="stats">
<thead><tr>
<th>{% trans "Language" %}</th><th>{% trans "Translated" %}</th>
{% if stat1.fig_count %}
<th></th>
{% endif %}
<th>{% trans "Graph" %}</th>
</tr></thead>
<!-- FIXME line / stat / stats naming -->
{% for line in stat %}
{% if not forloop.first %}
<tr>
<td class="leftcell"><a href="{{ line.po_url }}">{{ line.get_lang }}</a>
{% with line.most_important_message as msg %}
{% if msg %}
<img src="{{ msg.get_icon }}" title="{{ msg.get_description }}" alt="{{ msg.type }}" />
{% endif %}
{% endwith %}
{% if not forloop.first %}
<tr>
<td class="leftcell"><a href="{% url vertimus-stats-id-view line.id %}">{{ line.get_lang }}</a>
{% with line.most_important_message as msg %}
{% if msg %}
<img src="{{ msg.get_icon }}" title="{{ msg.get_description }}" alt="{{ msg.type }}" />
{% endif %}
{% endwith %}
</td>
<td>{{ line.get_translationstat|safe }}</td>
{% if stat1.fig_count %}
<td><a href="{% url stats.views.docimages module_name=module.name,potbase=stat1.domain.name,branch_name=branch.name,langcode=line.language.locale %}">
<img src="/media/img/figure.png" alt="{% trans "Display document figures" %}"></a></td>
<td><a href="{% url stats.views.docimages module_name=module.name,potbase=stat1.domain.name,branch_name=branch.name,langcode=line.language.locale %}">
<img src="/media/img/figure.png" alt="{% trans "Display document figures" %}"></a>
</td>
{% endif %}
<td style="width: 108px; text-align: center;"><div class="graph">
<div class="translated" style="width: {{ line.tr_percentage }}px;"></div>
<div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ line.tr_percentage }}px; width:{{ line.fu_percentage }}px;"></div>
<div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ line.tr_percentage|add:line.fu_percentage }}px; width: {{ line.un_percentage }}px;"></div>
<td style="width: 108px; text-align: center;">
<div class="graph">
<div class="translated" style="width: {{ line.tr_percentage }}px;"></div>
<div class="fuzzy" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ line.tr_percentage }}px; width:{{ line.fu_percentage }}px;"></div>
<div class="untranslated" style="{{ LANGUAGE_BIDI|yesno:"right,left" }}:{{ line.tr_percentage|add:line.fu_percentage }}px; width: {{ line.un_percentage }}px;"></div>
</div>
</td>
</tr>
{% endif %}
</tr>
{% endif %}
{% endfor %}
</table>
{% endwith %}
</table>
{% endfor %}
{% extends "base.html" %}
{% load i18n %}
{% block title %}
{% blocktrans with module.get_description as name %}Module Translation: {{ name }}{% endblocktrans %}
{% endblock %}
{% block content %}
<div class="mainpage">
<h1>{{ module.get_description }} - {{ branch.name }} - {% trans domain.description %} - {% trans language %}</h1>
{% if module.comment %}
<p>{{ module.comment|safe }}</p>
{% else %}
{% ifnotequal module.vcs_root "http://svn.gnome.org/svn" %}
<p><i><img src="/media/img/warn.png" alt="Warning logo" />{% trans "This module is not part of the GNOME SVN repository. Please check the module's web page to see where to send translations." %}</i></p>
{% endifnotequal %}
{% endif %}
<h3>State: {{ state }}
{% ifnotequal state.name 'none' %}
({{ state.updated|date:"D d M Y P" }})
{% endifnotequal %}
</h3>
<a href="{{ stats.po_url }}"><img src="/media/img/download.png" alt="Download POT file" /></a>
{{ stats.pot_text }}
{% if stats.information_set.all %}
<h4>{% trans "Notices" %}</h4>
<table>
{% for info in stats.information_set.all %}
<tr>
<td valign="top"><img src="{{ info.get_icon }}" alt="{{ info.type }}" /></td>
<td>{{ info.get_description|safe }}</td>
</tr>
{% endfor %}
</table>
{% endif %}
<table>
<tr>
<td>{% trans "Translated:" %}</td>
<td>{{ stats.get_translationstat|safe }}</td>
</tr>
<tr>
<td>{% trans "Graph:" %}</td>
<td><div class="graph">
<div class="translated" style="width: {{ stats.tr_percentage }}px;"></div>
<div class="fuzzy" style="left:{{ stats.tr_percentage }}px; width:{{ stats.fu_percentage }}px;"></div>
<div class="untranslated" style="left:{{ stats.tr_percentage|add:stats.fu_percentage }}px; width: {{ stats.un_percentage }}px;"></div>
</div>
</td>
</tr>
</table>
{% if stats.fig_count %}
<p><a href="{% url stats.views.docimages module_name=module.name,potbase=stats.domain.name,branch_name=branch.name,langcode=stats.language.locale %}">
<img src="/media/img/figure.png" alt="{% trans "Display document figures" %}"></a>
</p>
{% endif %}
{% if action_history %}
<h3>{% trans "Action History" %}</h3>
<table>
{% for action in action_history %}
<tr>
<td>{{ action }},
<img src="/media/img/person.png" alt="Person"/>
<!-- Spam protection -->
<a href="{{ action.person.get_absolute_url }}">{{ action.person.name }}</a>
{{ action.created }}
</td>
</tr>
<tr>
<td>
{% if action.file %}
{% trans "Uploaded file:" %} <a href="{{ action.file.url }}">{{ action.file.name }}</a>
{% if action.comment %}<br/>{% endif %}
{% endif %}
{{ action.comment|linebreaksbr|default:"No comment" }}<br/>
</td>
</tr>
<tr class="noborder"><td>&nbsp;</td></tr>
{% endfor %}
</table>
{% endif %}
<h3>{% trans "New Action" %}</h3>
{% if action_form %}
<form enctype="multipart/form-data" action="/vertimus/{{ stats.id }}" method="POST">
<table>
{{ action_form.as_table }}
<tr><td></td>
<td><input type="submit" value="Submit"></td><tr>
</table>
</form>
{% else %}
{% blocktrans with language.team.description as team_name %}You need to be authenticated and to be member of the {{ team_name }} team.{% endblocktrans %}
{% endif %}
{% endblock %}
......@@ -16,7 +16,7 @@ urlpatterns = patterns('',
# users is the hardcoded url in the contrib.auth User class, making it identical to /people
(r'^users/', include('people.urls')),
(r'^languages/', include('languages.urls')),
#(r'^stats/', include('stats.urls')),
(r'^vertimus/', include('vertimus.urls')),
(r'^admin/(.*)', admin.site.root),
)
......
This diff is collapsed.
......@@ -19,22 +19,54 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from django.test import TestCase
from django.core.files.storage import default_storage
from django.core.files.base import ContentFile
from django.conf import settings
from people.models import Person
from teams.models import Team
from teams.models import Team, Role
from languages.models import Language
from stats.models import Module, Branch, Release, Category, Domain
from vertimus.models import *
class VtmActionTests(TestCase):
class VertimusTests(TestCase):
def setUp(self):
self.p = Person(first_name='John', last_name='Lennon',
email='jlennon@beatles.com')
self.p.save()
self.pn = Person(first_name='John', last_name='Nothing',
email='jn@devnull.com', username= 'jn')
self.pn.save()
self.pt = Person(first_name='John', last_name='Translator',
email='jt@tf1.com', username= 'jt')
self.pt.save()
self.pr = Person(first_name='John', last_name='Reviewer',
email='jr@csa.com', username= 'jr')
self.pr.save()
self.pc = Person(first_name='John', last_name='Committer',
email='jc@alinsudesonpleingre.fr', username= 'jc')
self.pc.save()
self.pcoo = Person(first_name='John', last_name='Coordinator',
email='jcoo@imthebigboss.fr', username= 'jcoo')
self.pcoo.save()
self.t = Team(name='fr', description='French', coordinator=self.p)
self.t = Team(name='fr', description='French')
self.t.save()
self.role = Role(team=self.t, person=self.pt)
self.role.save()
self.role = Role(team=self.t, person=self.pr, role='reviewer')
self.role.save()
self.role = Role(team=self.t, person=self.pc, role='committer')
self.role.save()
self.role = Role(team=self.t, person=self.pcoo, role='coordinator')
self.role.save()
self.l = Language(name='french', locale='fr', team=self.t)
self.l.save()
......@@ -46,7 +78,8 @@ class VtmActionTests(TestCase):
self.m.save()
self.b = Branch(name='gnome-2-24', module=self.m)
self.b.save()
# Block the update of Statistics by the thread
self.b.save(update_statistics=False)
self.r = Release(name='gnome-2-24', status='official',
description='GNOME 2.24 (stable)',
......@@ -68,44 +101,277 @@ class VtmActionTests(TestCase):
self.b.delete()
self.m.delete()
self.l.delete()
for role in Role.objects.all():
role.delete()
self.t.delete()
self.p.delete()
self.pn.delete()
self.pt.delete()
self.pr.delete()
self.pc.delete()
self.pcoo.delete()
def test_action_wc(self):
a = VtmActionWC()
self.assertEquals(a.code, 'WC')
s_next = a.apply(self.b, self.d, self.l, self.p, 'Hi!')
self.assertEquals(s_next, None)
def test_state_none(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l)
sdb.name = 'None'
state = sdb.get_state()
self.assert_(isinstance(state, StateNone))
action_names = [a.name for a in state.get_available_actions(self.pn)]
self.assertEqual(action_names, ['WC'])
for p in (self.pt, self.pr, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['RT', 'WC'])
def test_state_translating(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
sdb.name = 'Translating'
state = sdb.get_state()
self.assert_(isinstance(state, StateTranslating))
for p in (self.pn, self.pr, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
# Same person
action_names = [a.name for a in state.get_available_actions(self.pt)]
self.assertEqual(action_names, ['UT', 'UNDO', 'WC'])
def test_state_translated(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
sdb.name = 'Translated'
state = sdb.get_state()
self.assert_(isinstance(state, StateTranslated))
action_names = [a.name for a in state.get_available_actions(self.pn)]
self.assertEqual(action_names, ['WC'])
action_names = [a.name for a in state.get_available_actions(self.pt)]
self.assertEqual(action_names, ['RT', 'TR', 'WC'])
for p in (self.pr, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['RP', 'RT', 'TR', 'WC'])
def test_state_proofreading(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
sdb.name = 'Proofreading'
state = sdb.get_state()
self.assert_(isinstance(state, StateProofreading))
for p in (self.pn, self.pt, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
# Same person and reviewer
action_names = [a.name for a in state.get_available_actions(self.pr)]
self.assertEqual(action_names, ['UP', 'TR', 'TC', 'UNDO', 'WC'])
def test_state_proofread(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
sdb.name = 'Proofread'
state = sdb.get_state()
self.assert_(isinstance(state, StateProofread))
for p in (self.pn, self.pt):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
for p in (self.pr, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['TC', 'TR', 'WC'])
def test_state_to_review(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pt)
sdb.name = 'ToReview'
state = sdb.get_state()
self.assert_(isinstance(state, StateToReview))
action_names = [a.name for a in state.get_available_actions(self.pn)]
self.assertEqual(action_names, ['WC'])
for p in (self.pt, self.pr, self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['RT', 'WC'])
def test_state_to_commit(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pr)
sdb.name = 'ToCommit'
state = sdb.get_state()
self.assert_(isinstance(state, StateToCommit))
for p in (self.pn, self.pt, self.pr):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['RC', 'TR', 'WC'])
def test_state_committing(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pc)
sdb.name = 'Committing'
state = sdb.get_state()
self.assert_(isinstance(state, StateCommitting))
for p in (self.pn, self.pt, self.pr, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
action_names = [a.name for a in state.get_available_actions(self.pc)]
self.assertEqual(action_names, ['IC', 'TR', 'UNDO', 'WC'])
def test_state_committed(self):
sdb = StateDb(branch=self.b, domain=self.d, language=self.l, person=self.pc)
sdb.name = 'Committed'
state = sdb.get_state()
self.assert_(isinstance(state, StateCommitted))
for p in (self.pn, self.pt, self.pr):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['WC'])
for p in (self.pc, self.pcoo):
action_names = [a.name for a in state.get_available_actions(p)]
self.assertEqual(action_names, ['BA', 'WC'])
def test_action_wc(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()
state.save()
action = ActionAbstract.new_by_name('WC')
new_state = state.apply_action(action, self.pt, "Hi!", None)
new_state.save()
def test_action_rt(self):
a = VtmActionRT()
self.assertEquals(a.code, 'RT')
s_next = a.apply(self.b, self.d, self.l, self.p, "Let's go!")
self.assertEquals(s_next.get_code(), 'Translating')
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()
state.save()
action = ActionAbstract.new_by_name('RT')
new_state = state.apply_action(action, self.pt, "Reserved!", None)
new_state.save()
def test_action_ut(self):
# Only the person who have reserved the translation is able to
# upload the new one
a = VtmActionRT()
s_current = a.apply(self.b, self.d, self.l, self.p, "Let's go!")
a = VtmActionUT()
self.assertEquals(a.code, 'UT')
s_next = s_current.apply_action(a, self.b, self.d, self.l, self.p, 'Just updated', 'fr.po')
self.assertEquals(s_next.get_code(), 'Translated')
def test_state_committed_action_wc(self):
s_current = VtmStateCommitted()
a_wc = None
# Writing a comment is always a possible action
for action in s_current.get_actions(self.b, self.d, self.l, self.p):
if isinstance(action, VtmActionWC):
a_wc = action
break
self.assertNotEquals(a_wc, None)
s_next = s_current.apply_action(a_wc, self.b, self.d, self.l, self.p, 'My comment')
self.assertEquals(s_current, s_next)
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translating', person=self.pt).get_state()
state.save()
action = ActionAbstract.new_by_name('UT')
new_state = state.apply_action(action, self.pt, "Done by translator.", 'myfile.po')
new_state.save()
def test_action_rp(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translated').get_state()
state.save()
action = ActionAbstract.new_by_name('RP')
new_state = state.apply_action(action, self.pr, "Reserved by a reviewer!")
new_state.save()
def test_action_up(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Proofreading', person=self.pr).get_state()
state.save()
action = ActionAbstract.new_by_name('UP')
new_state = state.apply_action(action, self.pr, "Done.", 'myfile.po')
new_state.save()
def test_action_tc(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Proofread').get_state()
state.save()
action = ActionAbstract.new_by_name('TC')
new_state = state.apply_action(action, self.pr, "Ready!")
new_state.save()
def test_action_rc(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='ToCommit').get_state()
state.save()
action = ActionAbstract.new_by_name('RC')
new_state = state.apply_action(action, self.pc, "This work is mine!")
new_state.save()
def test_action_ic(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Committing', person=self.pc).get_state()
state.save()
action = ActionAbstract.new_by_name('IC')
new_state = state.apply_action(action, self.pc, "Committed.")
new_state.save()
def test_action_tr(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Translated').get_state()
state.save()
action = ActionAbstract.new_by_name('TR')
new_state = state.apply_action(action, self.pc, "Bad work :-/")
new_state.save()
def test_action_ba(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='Proofreading', person=self.pr).get_state()
state.save()
# Create a new file
filename = 'mytestfile.po'
path = default_storage.save(settings.UPLOAD_DIR + filename, ContentFile('test content'))
action = ActionAbstract.new_by_name('UP')
state = state.apply_action(action, self.pr, "Done.", path)
state.save()
action = ActionAbstract.new_by_name('TC')
state = state.apply_action(action, self.pc, "To commit.")
state.save()
action = ActionAbstract.new_by_name('RC')
state = state.apply_action(action, self.pc, "Reserved commit.")
state.save()
action = ActionAbstract.new_by_name('IC')
state = state.apply_action(action, self.pc, "Committed.")
state.save()
action = ActionAbstract.new_by_name('BA')
state = state.apply_action(action, self.pc, comment="I don't want to disappear")
state.save()
self.assert_(not default_storage.exists(path))
self.assert_(default_storage.exists(settings.UPLOAD_BACKUP_DIR + '/' + filename))
# Remove test file
default_storage.delete(settings.UPLOAD_BACKUP_DIR + '/' + filename)
def test_action_undo(self):
state = StateDb(branch=self.b, domain=self.d, language=self.l, name='None').get_state()
state.save()
action = ActionAbstract.new_by_name('RT')
state = state.apply_action(action, self.pt, "Reserved!")
state.save()
action = ActionAbstract.new_by_name('UNDO')
state = state.apply_action(action, self.pt, "Ooops! I don't want to do that. Sorry.")
state.save()
self.assertEqual(state.name, 'None')
action = ActionAbstract.new_by_name('RT')
state = state.apply_action(action, self.pt, "Translating")
state.save()
action = ActionAbstract.new_by_name('UT')
state = state.apply_action(action, self.pt, "Translated")
state.save()
action = ActionAbstract.new_by_name('RT')
state = state.apply_action(action, self.pt, "Reserved!")
state.save()
action = ActionAbstract.new_by_name('UNDO')
state = state.apply_action(action, self.pt, "Ooops! I don't want to do that. Sorry.")
state.save()
self.assertEqual(state.name, 'Translated')
from django.conf.urls.defaults import *
urlpatterns = patterns('vertimus.views',
url(r'^(?P<stats_id>\d+)', 'vertimus_by_stats_id', name='vertimus-stats-id-view'),
url(r'^(?P<branch_id>\d+)/(?P<domain_id>\d+)/(?P<language_id>\d+)', 'vertimus_by_ids', name='vertimus-ids-view'),
url(r'^(?P<module_name>[\w\-\.]+)/(?P<branch_name>[\w\-]+)/(?P<domain_name>[\w\-]+)/(?P<locale_name>[\w\-@]+)', 'vertimus_by_names', name='vertimus-names-view')
)
# Create your views here.
# -*- coding: utf-8 -*-
#
# Copyright (c) 2008 Stéphane Raimbault <stephane.raimbault@gmail.com>
#
# This file is part of Damned Lies.
#
# Damned Lies is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# Damned Lies is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
from datetime import datetime
from django.shortcuts import render_to_response, get_object_or_404
from django.http import HttpResponseRedirect, Http404
from django.template import RequestContext
from django.utils.translation import ugettext_lazy as _
from django import forms
from django.core import urlresolvers
from django.conf import settings
from django.core.files.storage import default_storage
from people.models import Person
from stats.models import Statistics, Module, Branch, Domain, Language
from vertimus.models import StateDb, ActionDb, ActionAbstract
class ActionForm(forms.Form):
action = forms.ChoiceField(label=_("Action"),
# help_text="Choose an action you want to apply",
choices=())
comment = forms.CharField(label=_("Comment"),
# help_text="Leave a comment to explain your action",
max_length=1000,
required=False,
widget=forms.Textarea)
file = forms.FileField(label=_("File"), required=False)
def __init__(self, available_actions, *args, **kwargs):
super(ActionForm, self).__init__(*args, **kwargs)
self.fields['action'].choices = available_actions
def vertimus_by_stats_id(request, stats_id):
"""Access to Vertimus view by a Statistics ID"""
stats = get_object_or_404(Statistics, pk=stats_id)
return vertimus(request, stats.branch, stats.domain, stats.language, stats)
def vertimus_by_ids(request, branch_id, domain_id, language_id):