filling out user model and admin

This commit is contained in:
Jeff Balogh 2010-01-04 16:41:32 -05:00
Родитель 230105ac8e
Коммит de8c6ef38a
3 изменённых файлов: 47 добавлений и 4 удалений

Просмотреть файл

@ -34,6 +34,8 @@
<ul>
<li><a href="{{ url('admin:access_group_changelist') }}">
Configure Groups</a></li>
<li><a href="{{ url('admin:users_user_changelist') }}">
Manage a User</a></li>
</ul>
</li>
<li class="top">

11
apps/users/admin.py Normal file
Просмотреть файл

@ -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
import amo
from translations.fields import TranslatedField
class User(amo.ModelBase):
email = models.EmailField()
firstname = models.CharField(max_length=255)
lastname = models.CharField(max_length=255)
nickname = models.CharField(max_length=255)
email = models.EmailField(unique=True)
firstname = models.CharField(max_length=255, default='')
lastname = models.CharField(max_length=255, default='')
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:
db_table = 'users'
def __unicode__(self):
return '%s: %s' % (self.id, self.display_name)
def get_absolute_url(self):
# XXX: use reverse
return '/users/%s' % self.id