Absolute urls and view definitions

This commit is contained in:
Michal Čihař 2012-02-27 11:11:37 +01:00
parent 53e2f3137c
commit a5fbd3e90a
2 changed files with 15 additions and 0 deletions

View File

@ -10,6 +10,10 @@ class Project(models.Model):
mail = models.EmailField()
instructions = models.URLField()
@models.permalink
def get_absolute_url(self):
return ('trans.views.project', (), {'project': self.slug})
class SubProject(models.Model):
name = models.CharField(max_length = 100)
slug = models.SlugField(db_index = True)
@ -17,6 +21,10 @@ class SubProject(models.Model):
repo = models.CharField(max_length = 200)
branch = models.CharField(max_length = 50)
@models.permalink
def get_absolute_url(self):
return ('trans.views.subproject', (), {'project': self.project.slug, 'subproject': self.slug})
class Translation(models.Model):
subproject = models.ForeignKey(SubProject)
language = models.ForeignKey(Language)
@ -25,6 +33,10 @@ class Translation(models.Model):
revision = models.CharField(max_length = 40)
filename = models.CharField(max_length = 200)
@models.permalink
def get_absolute_url(self):
return ('trans.views.translation', (), {'project': self.subproject.slug, 'subproject': self.subproject.slug, 'lang': self.language.code})
class Unit(models.Model):
translation = models.ForeignKey(Translation)
location = models.TextField()

View File

@ -6,6 +6,9 @@ urlpatterns = patterns('',
# Examples:
# url(r'^$', 'weblate.views.home', name='home'),
# url(r'^weblate/', include('weblate.foo.urls')),
url(r'^(?P<project>[^/]*)/$', 'trans.views.project'),
url(r'^(?P<project>[^/]*)/(?P<subproject>[^/]*)/$', 'trans.views.subproject'),
url(r'^(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/$', 'trans.views.translation'),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', include(admin.site.urls)),