filling out user model and admin
This commit is contained in:
Родитель
230105ac8e
Коммит
de8c6ef38a
|
@ -34,6 +34,8 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><a href="{{ url('admin:access_group_changelist') }}">
|
<li><a href="{{ url('admin:access_group_changelist') }}">
|
||||||
Configure Groups</a></li>
|
Configure Groups</a></li>
|
||||||
|
<li><a href="{{ url('admin:users_user_changelist') }}">
|
||||||
|
Manage a User</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li class="top">
|
<li class="top">
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import User
|
||||||
|
|
||||||
|
|
||||||
|
class UserAdmin(admin.ModelAdmin):
|
||||||
|
list_display = ('__unicode__', 'email')
|
||||||
|
search_fields = ('^email',)
|
||||||
|
|
||||||
|
|
||||||
|
admin.site.register(User, UserAdmin)
|
|
@ -1,18 +1,48 @@
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
|
|
||||||
import amo
|
import amo
|
||||||
|
from translations.fields import TranslatedField
|
||||||
|
|
||||||
|
|
||||||
class User(amo.ModelBase):
|
class User(amo.ModelBase):
|
||||||
|
|
||||||
email = models.EmailField()
|
email = models.EmailField(unique=True)
|
||||||
firstname = models.CharField(max_length=255)
|
firstname = models.CharField(max_length=255, default='')
|
||||||
lastname = models.CharField(max_length=255)
|
lastname = models.CharField(max_length=255, default='')
|
||||||
nickname = models.CharField(max_length=255)
|
nickname = models.CharField(max_length=255, unique=True, null=True)
|
||||||
|
password = models.CharField(max_length=255, default='')
|
||||||
|
|
||||||
|
bio = TranslatedField()
|
||||||
|
location = models.CharField(max_length=255, default='')
|
||||||
|
occupation = models.CharField(max_length=255, default='')
|
||||||
|
picture_type = models.CharField(max_length=25, default='')
|
||||||
|
homepage = models.CharField(max_length=255, default='')
|
||||||
|
|
||||||
|
emailhidden = models.BooleanField(default=False)
|
||||||
|
display_collections = models.BooleanField(default=False)
|
||||||
|
display_collections_fav = models.BooleanField(default=False)
|
||||||
|
|
||||||
|
confirmationcode = models.CharField(max_length=255)
|
||||||
|
resetcode = models.CharField(max_length=255)
|
||||||
|
resetcode_expires = models.DateTimeField(default=datetime.now)
|
||||||
|
|
||||||
|
notifycompat = models.BooleanField(default=True)
|
||||||
|
notifyevents = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
deleted = models.BooleanField(default=True)
|
||||||
|
|
||||||
|
notes = models.TextField()
|
||||||
|
averagerating = models.CharField(max_length=255, blank=True, default='')
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
db_table = 'users'
|
db_table = 'users'
|
||||||
|
|
||||||
|
def __unicode__(self):
|
||||||
|
return '%s: %s' % (self.id, self.display_name)
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
# XXX: use reverse
|
# XXX: use reverse
|
||||||
return '/users/%s' % self.id
|
return '/users/%s' % self.id
|
||||||
|
|
Загрузка…
Ссылка в новой задаче