Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
60ceab11
authored
Feb 06, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: user specific language
parent
21300d42
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
104 additions
and
2 deletions
+104
-2
cloud/settings.py
+1
-1
school/migrations/0008_auto__add_field_person_language.py
+93
-0
school/models.py
+7
-0
school/views.py
+3
-1
No files found.
cloud/settings.py
View file @
60ceab11
...
...
@@ -29,7 +29,7 @@ TIME_ZONE = 'Europe/Budapest'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE
=
'hu
-hu
'
LANGUAGE_CODE
=
'hu'
SITE_ID
=
1
...
...
school/migrations/0008_auto__add_field_person_language.py
0 → 100644
View file @
60ceab11
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
SchemaMigration
from
django.db
import
models
class
Migration
(
SchemaMigration
):
def
forwards
(
self
,
orm
):
# Adding field 'Person.language'
db
.
add_column
(
'school_person'
,
'language'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'hu'
,
max_length
=
10
),
keep_default
=
False
)
def
backwards
(
self
,
orm
):
# Deleting field 'Person.language'
db
.
delete_column
(
'school_person'
,
'language'
)
models
=
{
'auth.group'
:
{
'Meta'
:
{
'object_name'
:
'Group'
},
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'80'
}),
'permissions'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
"orm['auth.Permission']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
})
},
'auth.permission'
:
{
'Meta'
:
{
'ordering'
:
"('content_type__app_label', 'content_type__model', 'codename')"
,
'unique_together'
:
"(('content_type', 'codename'),)"
,
'object_name'
:
'Permission'
},
'codename'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'content_type'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['contenttypes.ContentType']"
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'50'
})
},
'auth.user'
:
{
'Meta'
:
{
'object_name'
:
'User'
},
'date_joined'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'email'
:
(
'django.db.models.fields.EmailField'
,
[],
{
'max_length'
:
'75'
,
'blank'
:
'True'
}),
'first_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
,
'blank'
:
'True'
}),
'groups'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
"orm['auth.Group']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'is_active'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'True'
}),
'is_staff'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'is_superuser'
:
(
'django.db.models.fields.BooleanField'
,
[],
{
'default'
:
'False'
}),
'last_login'
:
(
'django.db.models.fields.DateTimeField'
,
[],
{
'default'
:
'datetime.datetime.now'
}),
'last_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
,
'blank'
:
'True'
}),
'password'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'128'
}),
'user_permissions'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'to'
:
"orm['auth.Permission']"
,
'symmetrical'
:
'False'
,
'blank'
:
'True'
}),
'username'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'30'
})
},
'contenttypes.contenttype'
:
{
'Meta'
:
{
'ordering'
:
"('name',)"
,
'unique_together'
:
"(('app_label', 'model'),)"
,
'object_name'
:
'ContentType'
,
'db_table'
:
"'django_content_type'"
},
'app_label'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'model'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'100'
})
},
'school.course'
:
{
'Meta'
:
{
'object_name'
:
'Course'
},
'code'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'20'
}),
'default_group'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"'default_group_of'"
,
'null'
:
'True'
,
'to'
:
"orm['school.Group']"
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'80'
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'owners'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'symmetrical'
:
'False'
,
'to'
:
"orm['school.Person']"
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'short_name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'10'
,
'null'
:
'True'
,
'blank'
:
'True'
})
},
'school.group'
:
{
'Meta'
:
{
'unique_together'
:
"(('name', 'course', 'semester'),)"
,
'object_name'
:
'Group'
},
'course'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['school.Course']"
,
'null'
:
'True'
,
'blank'
:
'True'
}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'members'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"'course_groups'"
,
'null'
:
'True'
,
'symmetrical'
:
'False'
,
'to'
:
"orm['school.Person']"
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'80'
}),
'owners'
:
(
'django.db.models.fields.related.ManyToManyField'
,
[],
{
'blank'
:
'True'
,
'related_name'
:
"'owned_groups'"
,
'null'
:
'True'
,
'symmetrical'
:
'False'
,
'to'
:
"orm['school.Person']"
}),
'semester'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['school.Semester']"
})
},
'school.person'
:
{
'Meta'
:
{
'object_name'
:
'Person'
},
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'language'
:
(
'django.db.models.fields.CharField'
,
[],
{
'default'
:
"'hu'"
,
'max_length'
:
'10'
}),
'user'
:
(
'django.db.models.fields.related.ForeignKey'
,
[],
{
'to'
:
"orm['auth.User']"
,
'unique'
:
'True'
})
},
'school.semester'
:
{
'Meta'
:
{
'object_name'
:
'Semester'
},
'end'
:
(
'django.db.models.fields.DateField'
,
[],
{}),
'id'
:
(
'django.db.models.fields.AutoField'
,
[],
{
'primary_key'
:
'True'
}),
'name'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'20'
}),
'start'
:
(
'django.db.models.fields.DateField'
,
[],
{})
}
}
complete_apps
=
[
'school'
]
\ No newline at end of file
school/models.py
View file @
60ceab11
...
...
@@ -4,6 +4,11 @@ from django.contrib.auth.models import User
from
django.db.models.signals
import
post_save
from
django.core.exceptions
import
ValidationError
from
datetime
import
datetime
from
django.conf
import
settings
LANGUAGE_CODE
=
settings
.
LANGUAGE_CODE
LANGUAGE_CHOICES
=
((
'hu'
,
_
(
'Hungarian'
)),
(
'en'
,
_
(
'English'
)))
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
...
...
@@ -15,6 +20,8 @@ post_save.connect(create_user_profile, sender=User)
class
Person
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
null
=
False
,
blank
=
False
,
unique
=
True
)
language
=
models
.
CharField
(
verbose_name
=
_
(
'language'
),
blank
=
False
,
max_length
=
10
,
choices
=
LANGUAGE_CHOICES
,
default
=
LANGUAGE_CODE
)
def
short_name
(
self
):
if
self
.
user
.
last_name
:
...
...
school/views.py
View file @
60ceab11
...
...
@@ -111,4 +111,6 @@ def login(request):
redirect_to
=
request
.
REQUEST
.
get
(
auth
.
REDIRECT_FIELD_NAME
,
''
)
if
not
is_safe_url
(
url
=
redirect_to
,
host
=
request
.
get_host
()):
redirect_to
=
settings
.
LOGIN_REDIRECT_URL
return
redirect
(
redirect_to
)
response
=
redirect
(
redirect_to
)
response
.
set_cookie
(
settings
.
LANGUAGE_COOKIE_NAME
,
p
.
language
,
10
*
365
*
24
*
3600
)
return
response
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment