users app
This commit is contained in:
Родитель
dfb4df89e3
Коммит
85032f5482
|
@ -0,0 +1,25 @@
|
|||
from django.db import models
|
||||
|
||||
import amo
|
||||
|
||||
|
||||
class User(amo.LegacyModel):
|
||||
|
||||
email = models.EmailField()
|
||||
firstname = models.CharField(max_length=255)
|
||||
lastname = models.CharField(max_length=255)
|
||||
nickname = models.CharField(max_length=255)
|
||||
|
||||
class Meta:
|
||||
db_table = 'users'
|
||||
|
||||
def get_absolute_url(self):
|
||||
# XXX: use reverse
|
||||
return '/users/%s' % self.id
|
||||
|
||||
@property
|
||||
def display_name(self):
|
||||
if not self.nickname:
|
||||
return '%s %s' % (self.firstname, self.lastname)
|
||||
else:
|
||||
return self.nickname
|
|
@ -0,0 +1,9 @@
|
|||
import jinja2
|
||||
|
||||
from jingo import register
|
||||
|
||||
|
||||
@register.filter
|
||||
def user_link(user):
|
||||
return jinja2.Markup('<a href="%s">%s</a>' %
|
||||
(user.get_absolute_url(), user.display_name))
|
Загрузка…
Ссылка в новой задаче