Added profile, with css theme

svn: r13959
This commit is contained in:
Doug Blank 2010-01-02 16:34:37 +00:00
parent f58e700e86
commit e39b3b68ea
8 changed files with 78 additions and 17 deletions

View File

@ -4,3 +4,4 @@ from django.contrib import admin
for type_name in get_tables("all"): for type_name in get_tables("all"):
admin.site.register(type_name[1]) admin.site.register(type_name[1])
admin.site.register(Profile)

View File

@ -18,7 +18,7 @@
"setting" : "db_created" , "setting" : "db_created" ,
"description" : "database creation date/time" , "description" : "database creation date/time" ,
"value_type" : "str" , "value_type" : "str" ,
"value" : "2010-01-01 10:12" "value" : "2010-01-02 11:30"
} }
}, },
{ {

View File

@ -36,6 +36,8 @@ from django.contrib.contenttypes import generic
from gen.lib.date import Date as GDate, Today from gen.lib.date import Date as GDate, Today
from Utils import create_id, create_uid from Utils import create_id, create_uid
from web.grampsdb.profile import Profile
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# #
# Support functions # Support functions
@ -290,7 +292,21 @@ class DateNewYearType(mGrampsType):
_DEFAULT = _DATAMAP[NEWYEAR_JAN1] _DEFAULT = _DATAMAP[NEWYEAR_JAN1]
val = models.IntegerField('New Year start date', choices=_DATAMAP, blank=False) val = models.IntegerField('New Year start date', choices=_DATAMAP, blank=False)
class ThemeType(mGrampsType):
_DATAMAP = list(enumerate(["Web_Mainz.css",
"Web_Basic-Ash.css",
"Web_Basic-Cypress.css",
"Web_Nebraska.css",
"Web_Basic-Lilac.css",
"Web_Print-Default.css",
"Web_Basic-Peach.css",
"Web_Visually.css",
"Web_Basic-Spruce.css",]))
_DEFAULT = _DATAMAP[0]
val = models.IntegerField('Theme', choices=_DATAMAP, blank=False)
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# #
# Support definitions # Support definitions
@ -737,6 +753,7 @@ TABLES = [
("type", GenderType), ("type", GenderType),
("type", LdsType), ("type", LdsType),
("type", LdsStatus), ("type", LdsStatus),
("type", ThemeType),
("abstract", DateObject), ("abstract", DateObject),
("meta", Config), ("meta", Config),
("abstract", PrimaryObject), ("abstract", PrimaryObject),

View File

@ -0,0 +1,48 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2009 Douglas S. Blank <doug.blank@gmail.com>
#
# This program 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.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id$
#
from django.db import models
from django.db.models.signals import post_save
from django.contrib.auth.models import User
class Profile(models.Model):
"""
Used to save additional information of a user, such as
themes, bookmarks, etc.
"""
user = models.ForeignKey(User, unique=True)
css_theme = models.CharField(max_length=40,
default="Web_Mainz.css")
def __unicode__(self):
return unicode(self.user)
def save_profile(sender, instance, created, **kwargs):
"""
Creates the profile when the user gets created.
"""
if created:
profile = Profile(user=instance)
profile.save()
else:
print sender
post_save.connect(save_profile, sender=User)

View File

@ -65,27 +65,19 @@ def context_processor(request):
This function is executed before template processing. This function is executed before template processing.
takes a request, and returns a dictionary context. takes a request, and returns a dictionary context.
""" """
# FIXME: make the css_theme based on user's selection
context = {} context = {}
context["css_theme"] = "Web_Mainz.css" if request.user.is_authenticated():
# FIXME: get the views from a config? profile = request.user.get_profile()
context["css_theme"] = profile.css_theme
else:
context["css_theme"] = "Web_Mainz.css"
# Other things for all environments:
context["views"] = VIEWS context["views"] = VIEWS
context["True"] = True context["True"] = True
context["False"] = False context["False"] = False
context["default"] = "" context["default"] = ""
return context return context
# CSS Themes:
#Web_Basic-Ash.css
#Web_Mainz.css
#Web_Basic-Cypress.css
#Web_Nebraska.css
#Web_Basic-Lilac.css
#Web_Print-Default.css
#Web_Basic-Peach.css
#Web_Visually.css
#Web_Basic-Spruce.css
def main_page(request): def main_page(request):
context = RequestContext(request) context = RequestContext(request)
context["view"] = 'home' context["view"] = 'home'

View File

@ -43,7 +43,8 @@ from gen.lib.srcmediatype import SourceMediaType
from gen.lib.eventroletype import EventRoleType from gen.lib.eventroletype import EventRoleType
from gen.lib.notetype import NoteType from gen.lib.notetype import NoteType
from grampsdb.models import GenderType, LdsType, LdsStatus, NameFormatType from grampsdb.models import (GenderType, LdsType, LdsStatus,
NameFormatType, ThemeType)
def get_datamap(x): def get_datamap(x):
""" """

View File

@ -111,6 +111,8 @@ DEBUG_TOOLBAR_CONFIG = {
'HIDE_DJANGO_SQL': False, 'HIDE_DJANGO_SQL': False,
} }
AUTH_PROFILE_MODULE = "grampsdb.Profile"
# Had to add these to use settings.configure(): # Had to add these to use settings.configure():
DATABASE_OPTIONS = '' DATABASE_OPTIONS = ''
URL_VALIDATOR_USER_AGENT = '' URL_VALIDATOR_USER_AGENT = ''

Binary file not shown.