Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
7434cd62
authored
Feb 08, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: add Person.code
parent
66cc1717
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
289 additions
and
3 deletions
+289
-3
school/migrations/0009_auto__add_field_person_code__chg_field_person_user.py
+99
-0
school/migrations/0010_neptuncodes.py
+90
-0
school/migrations/0011_auto__add_unique_person_code.py
+92
-0
school/models.py
+8
-3
No files found.
school/migrations/0009_auto__add_field_person_code__chg_field_person_user.py
0 → 100644
View file @
7434cd62
# -*- 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.code'
db
.
add_column
(
'school_person'
,
'code'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'MIGRATEME'
,
max_length
=
30
),
keep_default
=
False
)
# Changing field 'Person.user'
db
.
alter_column
(
'school_person'
,
'user_id'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'auth.User'
],
unique
=
True
,
null
=
True
))
def
backwards
(
self
,
orm
):
# Deleting field 'Person.code'
db
.
delete_column
(
'school_person'
,
'code'
)
# User chose to not deal with backwards NULL issues for 'Person.user'
raise
RuntimeError
(
"Cannot reverse this migration. 'Person.user' and its values cannot be restored."
)
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'
},
'code'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
}),
'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'
,
'null'
:
'True'
,
'blank'
:
'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'
]
school/migrations/0010_neptuncodes.py
0 → 100644
View file @
7434cd62
# -*- coding: utf-8 -*-
import
datetime
from
south.db
import
db
from
south.v2
import
DataMigration
from
django.db
import
models
class
Migration
(
DataMigration
):
def
forwards
(
self
,
orm
):
"Write your forwards methods here."
for
person
in
orm
[
'school.Person'
]
.
objects
.
all
():
person
.
code
=
person
.
user
.
username
person
.
save
()
def
backwards
(
self
,
orm
):
raise
RuntimeError
(
"Cannot reverse this migration."
)
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'
},
'code'
:
(
'django.db.models.fields.CharField'
,
[],
{
'max_length'
:
'30'
}),
'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'
,
'null'
:
'True'
,
'blank'
:
'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'
]
symmetrical
=
True
school/migrations/0011_auto__add_unique_person_code.py
0 → 100644
View file @
7434cd62
# -*- 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 unique constraint on 'Person', fields ['code']
db
.
create_unique
(
'school_person'
,
[
'code'
])
def
backwards
(
self
,
orm
):
# Removing unique constraint on 'Person', fields ['code']
db
.
delete_unique
(
'school_person'
,
[
'code'
])
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'
},
'code'
:
(
'django.db.models.fields.CharField'
,
[],
{
'unique'
:
'True'
,
'max_length'
:
'30'
}),
'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'
,
'null'
:
'True'
,
'blank'
:
'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 @
7434cd62
...
...
@@ -13,15 +13,20 @@ LANGUAGE_CHOICES = (('hu', _('Hungarian')), ('en', _('English')))
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
try
:
Person
.
objects
.
create
(
user
=
instance
)
p
=
Person
.
objects
.
get
(
code
=
instance
.
username
)
except
Exception
:
p
=
Person
.
objects
.
create
(
code
=
instance
.
username
)
except
:
pass
return
p
.
code
=
instance
.
username
p
.
save
()
post_save
.
connect
(
create_user_profile
,
sender
=
User
)
class
Person
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
null
=
False
,
blank
=
Fals
e
,
unique
=
True
)
user
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
Tru
e
,
unique
=
True
)
language
=
models
.
CharField
(
verbose_name
=
_
(
'language'
),
blank
=
False
,
max_length
=
10
,
choices
=
LANGUAGE_CHOICES
,
default
=
LANGUAGE_CODE
)
code
=
models
.
CharField
(
_
(
'code'
),
max_length
=
30
,
unique
=
True
)
def
short_name
(
self
):
if
self
.
user
.
last_name
:
...
...
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