Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gyuricska Milán
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
78691dd0
authored
Feb 06, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'i18n'
parents
021e8d35
35b36992
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
7 deletions
+129
-7
cloud/settings.py
+2
-1
cloud/urls.py
+1
-0
one/templates/base.html
+2
-5
school/migrations/0008_auto__add_field_person_language.py
+93
-0
school/models.py
+7
-0
school/views.py
+24
-1
No files found.
cloud/settings.py
View file @
78691dd0
...
...
@@ -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
...
...
@@ -92,6 +92,7 @@ TEMPLATE_LOADERS = (
MIDDLEWARE_CLASSES
=
(
'django.middleware.common.CommonMiddleware'
,
'django.contrib.sessions.middleware.SessionMiddleware'
,
'django.middleware.locale.LocaleMiddleware'
,
'django.middleware.csrf.CsrfViewMiddleware'
,
'django.middleware.transaction.TransactionMiddleware'
,
'django.contrib.auth.middleware.AuthenticationMiddleware'
,
...
...
cloud/urls.py
View file @
78691dd0
...
...
@@ -35,4 +35,5 @@ urlpatterns = patterns('',
url
(
r'^ajax/store/newFolder$'
,
'store.views.ajax_new_folder'
,
name
=
'store_ajax_new_folder'
),
url
(
r'^ajax/store/quota$'
,
'store.views.ajax_quota'
,
name
=
'store_ajax_quota'
),
url
(
r'^ajax/store/rename$'
,
'store.views.ajax_rename'
,
name
=
'store_ajax_rename'
),
url
(
r'^language/(?P<lang>[-A-Za-z]+)/$'
,
'school.views.language'
,
name
=
'language'
),
)
one/templates/base.html
View file @
78691dd0
...
...
@@ -31,14 +31,11 @@
{% else %}
<a
href=
"/login/"
>
Bejelentkezés
</a>
.
{% endif %}
<!--
{% if lang == 'hu' %}
<a href="/language/en
-US
/">In English</a>.
{% if lang == 'hu' %}
<a
href=
"/language/en/"
>
In English
</a>
.
{% else %}
<a
href=
"/language/hu/"
>
Magyarul
</a>
.
{% if autolang %}
<p style="position: absolute; top: 40px; right: 1em;" class="triangle-border top">Böngészője kifejezetten angol tartalmat kért.<br/>A <a href="/language/hu/">magyar változat</a> részletesebb és frissebb!</p>
{% endif %}
{% endif %}-->
</p>
</div>
{% endblock %}
...
...
school/migrations/0008_auto__add_field_person_language.py
0 → 100644
View file @
78691dd0
# -*- 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 @
78691dd0
...
...
@@ -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 @
78691dd0
...
...
@@ -111,4 +111,27 @@ 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
def
language
(
request
,
lang
):
cname
=
settings
.
LANGUAGE_COOKIE_NAME
if
not
cname
:
cname
=
'django_language'
redirect_to
=
request
.
META
[
'HTTP_REFERER'
]
r
=
redirect
(
redirect_to
)
if
not
redirect_to
:
redirect_to
=
"/"
try
:
p
=
Person
.
objects
.
get
(
user
=
request
.
user
)
p
.
language
=
lang
p
.
save
()
except
ValidationError
as
e
:
messages
.
error
(
e
)
except
:
messages
.
error
(
_
(
"Could not found Person object."
))
r
.
set_cookie
(
cname
,
lang
,
10
*
365
*
24
*
3600
)
return
r
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