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
d823c2ba
authored
Feb 02, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
school: new simple school model
ref #30
parent
c0e5d189
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
340 additions
and
38 deletions
+340
-38
school/migrations/0002_auto__del_entity__del_lessonclass__del_lesson__del_person__del_mark__d.py
+134
-0
school/migrations/0003_auto__add_course__add_semester__add_person__add_group__add_unique_grou.py
+166
-0
school/models.py
+40
-38
No files found.
school/migrations/0002_auto__del_entity__del_lessonclass__del_lesson__del_person__del_mark__d.py
0 → 100644
View file @
d823c2ba
# -*- 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
):
# Deleting model 'Entity'
db
.
delete_table
(
'school_entity'
)
# Deleting model 'LessonClass'
db
.
delete_table
(
'school_lessonclass'
)
# Deleting model 'Lesson'
db
.
delete_table
(
'school_lesson'
)
# Deleting model 'Person'
db
.
delete_table
(
'school_person'
)
# Deleting model 'Mark'
db
.
delete_table
(
'school_mark'
)
# Deleting model 'Course'
db
.
delete_table
(
'school_course'
)
# Deleting model 'Semester'
db
.
delete_table
(
'school_semester'
)
# Deleting model 'Event'
db
.
delete_table
(
'school_event'
)
# Deleting model 'Attendance'
db
.
delete_table
(
'school_attendance'
)
# Deleting model 'Group'
db
.
delete_table
(
'school_group'
)
def
backwards
(
self
,
orm
):
# Adding model 'Entity'
db
.
create_table
(
'school_entity'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'parent'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Group'
])),
(
'name'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
100
)),
))
db
.
send_create_signal
(
'school'
,
[
'Entity'
])
# Adding model 'LessonClass'
db
.
create_table
(
'school_lessonclass'
,
(
(
'group'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Group'
])),
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'LessonClass'
])
# Adding model 'Lesson'
db
.
create_table
(
'school_lesson'
,
(
(
'group'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Group'
])),
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'lesson_class'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.LessonClass'
])),
))
db
.
send_create_signal
(
'school'
,
[
'Lesson'
])
# Adding model 'Person'
db
.
create_table
(
'school_person'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'language'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
default
=
'hu'
,
max_length
=
6
)),
(
'user'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'auth.User'
],
unique
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'Person'
])
# Adding model 'Mark'
db
.
create_table
(
'school_mark'
,
(
(
'modified_by'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
related_name
=
'modified_marks'
,
to
=
orm
[
'school.Person'
])),
(
'value'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
100
)),
(
'student'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Person'
])),
(
'created_at'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)(
auto_now_add
=
True
,
blank
=
True
)),
(
'modified_at'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)(
auto_now
=
True
,
blank
=
True
)),
(
'event'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Event'
])),
(
'created_by'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
related_name
=
'created_marks'
,
to
=
orm
[
'school.Person'
])),
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'Mark'
])
# Adding model 'Course'
db
.
create_table
(
'school_course'
,
(
(
'entity_ptr'
,
self
.
gf
(
'django.db.models.fields.related.OneToOneField'
)(
to
=
orm
[
'school.Entity'
],
unique
=
True
,
primary_key
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'Course'
])
# Adding model 'Semester'
db
.
create_table
(
'school_semester'
,
(
(
'entity_ptr'
,
self
.
gf
(
'django.db.models.fields.related.OneToOneField'
)(
to
=
orm
[
'school.Entity'
],
unique
=
True
,
primary_key
=
True
)),
(
'start'
,
self
.
gf
(
'django.db.models.fields.DateField'
)()),
(
'end'
,
self
.
gf
(
'django.db.models.fields.DateField'
)()),
))
db
.
send_create_signal
(
'school'
,
[
'Semester'
])
# Adding model 'Event'
db
.
create_table
(
'school_event'
,
(
(
'type'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
5
)),
(
'group'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Group'
])),
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'title'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
100
)),
))
db
.
send_create_signal
(
'school'
,
[
'Event'
])
# Adding model 'Attendance'
db
.
create_table
(
'school_attendance'
,
(
(
'modified_by'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
related_name
=
'modified_attendances'
,
to
=
orm
[
'school.Person'
])),
(
'modified_at'
,
self
.
gf
(
'django.db.models.fields.DateTimeField'
)(
auto_now
=
True
,
blank
=
True
)),
(
'student'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Person'
])),
(
'lesson'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Lesson'
])),
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'present'
,
self
.
gf
(
'django.db.models.fields.NullBooleanField'
)(
null
=
True
,
blank
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'Attendance'
])
# Adding model 'Group'
db
.
create_table
(
'school_group'
,
(
(
'entity_ptr'
,
self
.
gf
(
'django.db.models.fields.related.OneToOneField'
)(
to
=
orm
[
'school.Entity'
],
unique
=
True
,
primary_key
=
True
)),
(
'recursive_unique'
,
self
.
gf
(
'django.db.models.fields.BooleanField'
)(
default
=
False
)),
))
db
.
send_create_signal
(
'school'
,
[
'Group'
])
models
=
{
}
complete_apps
=
[
'school'
]
\ No newline at end of file
school/migrations/0003_auto__add_course__add_semester__add_person__add_group__add_unique_grou.py
0 → 100644
View file @
d823c2ba
# -*- 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 model 'Course'
db
.
create_table
(
'school_course'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'code'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
unique
=
True
,
max_length
=
10
)),
(
'name'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
max_length
=
80
,
null
=
True
,
blank
=
True
)),
(
'default_group'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
blank
=
True
,
related_name
=
'default_group_of'
,
null
=
True
,
to
=
orm
[
'school.Group'
])),
))
db
.
send_create_signal
(
'school'
,
[
'Course'
])
# Adding M2M table for field owners on 'Course'
db
.
create_table
(
'school_course_owners'
,
(
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
primary_key
=
True
,
auto_created
=
True
)),
(
'course'
,
models
.
ForeignKey
(
orm
[
'school.course'
],
null
=
False
)),
(
'user'
,
models
.
ForeignKey
(
orm
[
'auth.user'
],
null
=
False
))
))
db
.
create_unique
(
'school_course_owners'
,
[
'course_id'
,
'user_id'
])
# Adding model 'Semester'
db
.
create_table
(
'school_semester'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'start'
,
self
.
gf
(
'django.db.models.fields.DateField'
)()),
(
'end'
,
self
.
gf
(
'django.db.models.fields.DateField'
)()),
))
db
.
send_create_signal
(
'school'
,
[
'Semester'
])
# Adding model 'Person'
db
.
create_table
(
'school_person'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'user'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'auth.User'
],
unique
=
True
)),
))
db
.
send_create_signal
(
'school'
,
[
'Person'
])
# Adding model 'Group'
db
.
create_table
(
'school_group'
,
(
(
'id'
,
self
.
gf
(
'django.db.models.fields.AutoField'
)(
primary_key
=
True
)),
(
'name'
,
self
.
gf
(
'django.db.models.fields.CharField'
)(
unique
=
True
,
max_length
=
80
)),
(
'course'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Course'
],
null
=
True
,
blank
=
True
)),
(
'semester'
,
self
.
gf
(
'django.db.models.fields.related.ForeignKey'
)(
to
=
orm
[
'school.Semester'
])),
))
db
.
send_create_signal
(
'school'
,
[
'Group'
])
# Adding M2M table for field owners on 'Group'
db
.
create_table
(
'school_group_owners'
,
(
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
primary_key
=
True
,
auto_created
=
True
)),
(
'group'
,
models
.
ForeignKey
(
orm
[
'school.group'
],
null
=
False
)),
(
'user'
,
models
.
ForeignKey
(
orm
[
'auth.user'
],
null
=
False
))
))
db
.
create_unique
(
'school_group_owners'
,
[
'group_id'
,
'user_id'
])
# Adding M2M table for field members on 'Group'
db
.
create_table
(
'school_group_members'
,
(
(
'id'
,
models
.
AutoField
(
verbose_name
=
'ID'
,
primary_key
=
True
,
auto_created
=
True
)),
(
'group'
,
models
.
ForeignKey
(
orm
[
'school.group'
],
null
=
False
)),
(
'user'
,
models
.
ForeignKey
(
orm
[
'auth.user'
],
null
=
False
))
))
db
.
create_unique
(
'school_group_members'
,
[
'group_id'
,
'user_id'
])
# Adding unique constraint on 'Group', fields ['name', 'course', 'semester']
db
.
create_unique
(
'school_group'
,
[
'name'
,
'course_id'
,
'semester_id'
])
def
backwards
(
self
,
orm
):
# Removing unique constraint on 'Group', fields ['name', 'course', 'semester']
db
.
delete_unique
(
'school_group'
,
[
'name'
,
'course_id'
,
'semester_id'
])
# Deleting model 'Course'
db
.
delete_table
(
'school_course'
)
# Removing M2M table for field owners on 'Course'
db
.
delete_table
(
'school_course_owners'
)
# Deleting model 'Semester'
db
.
delete_table
(
'school_semester'
)
# Deleting model 'Person'
db
.
delete_table
(
'school_person'
)
# Deleting model 'Group'
db
.
delete_table
(
'school_group'
)
# Removing M2M table for field owners on 'Group'
db
.
delete_table
(
'school_group_owners'
)
# Removing M2M table for field members on 'Group'
db
.
delete_table
(
'school_group_members'
)
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'
:
'10'
}),
'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['auth.User']"
,
'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['auth.User']"
}),
'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['auth.User']"
}),
'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'
}),
'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'
}),
'start'
:
(
'django.db.models.fields.DateField'
,
[],
{})
}
}
complete_apps
=
[
'school'
]
\ No newline at end of file
school/models.py
View file @
d823c2ba
...
@@ -2,63 +2,65 @@ from django.db import models
...
@@ -2,63 +2,65 @@ from django.db import models
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.utils.translation
import
ugettext_lazy
as
_
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.db.models.signals
import
post_save
from
django.db.models.signals
import
post_save
from
django.core.exceptions
import
ValidationError
from
datetime
import
datetime
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
def
create_user_profile
(
sender
,
instance
,
created
,
**
kwargs
):
if
created
:
if
created
:
try
:
Person
.
objects
.
create
(
user
=
instance
)
Person
.
objects
.
create
(
user
=
instance
)
except
:
pass
post_save
.
connect
(
create_user_profile
,
sender
=
User
)
post_save
.
connect
(
create_user_profile
,
sender
=
User
)
LANGS
=
[(
'hu'
,
_
(
'Hungarian'
)),
(
'en_US'
,
_
(
'US English'
))]
class
Person
(
models
.
Model
):
class
Person
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
null
=
False
,
blank
=
False
,
unique
=
True
)
user
=
models
.
ForeignKey
(
User
,
null
=
False
,
blank
=
False
,
unique
=
True
)
language
=
models
.
CharField
(
max_length
=
6
,
choices
=
LANGS
,
default
=
'hu'
,
verbose_name
=
_
(
'Preferred language'
))
def
__unicode__
(
self
):
def
__unicode__
(
self
):
return
self
.
user
.
__unicode__
()
return
self
.
user
.
__unicode__
()
class
Entity
(
models
.
Model
):
class
Course
(
models
.
Model
):
parent
=
models
.
ForeignKey
(
'school.Group'
)
code
=
models
.
CharField
(
max_length
=
10
,
unique
=
True
)
name
=
models
.
CharField
(
max_length
=
100
)
name
=
models
.
CharField
(
max_length
=
80
,
null
=
True
,
blank
=
True
)
default_group
=
models
.
ForeignKey
(
'Group'
,
null
=
True
,
blank
=
True
,
related_name
=
'default_group_of'
)
owners
=
models
.
ManyToManyField
(
User
,
blank
=
True
,
null
=
True
)
def
get_or_create_default_group
(
self
):
self
.
default_group
=
Group
(
name
=
self
.
name
,
semester
=
Semester
.
get_current
())
self
.
default_group
.
save
()
def
save
(
self
,
*
args
,
**
kwargs
):
if
self
.
default_group
:
self
.
default_group
.
course
=
self
self
.
default_group
.
save
()
self
.
full_clean
()
super
(
Course
,
self
)
.
save
(
*
args
,
**
kwargs
)
class
Group
(
Entity
):
recursive_unique
=
models
.
BooleanField
()
class
Course
(
Entity
):
pass
class
Semester
(
Entity
):
class
Semester
(
models
.
Model
):
start
=
models
.
DateField
()
start
=
models
.
DateField
()
end
=
models
.
DateField
()
end
=
models
.
DateField
()
EVENT_CHOICES
=
[(
'free'
,
_
(
'free text'
)),
(
'num'
,
_
(
'number'
)),
(
'int'
,
_
(
'integer'
))]
def
is_on
(
self
,
time
):
class
Event
(
models
.
Model
):
return
self
.
start
<=
time
.
date
()
and
self
.
end
>=
time
.
date
()
title
=
models
.
CharField
(
max_length
=
100
)
group
=
models
.
ForeignKey
(
'school.Group'
)
type
=
models
.
CharField
(
max_length
=
5
,
choices
=
EVENT_CHOICES
)
class
Mark
(
models
.
Model
):
@classmethod
value
=
models
.
CharField
(
max_length
=
100
)
def
get_current
(
cls
):
student
=
models
.
ForeignKey
(
'Person'
)
n
=
datetime
.
now
(
)
event
=
models
.
ForeignKey
(
'school.Event'
)
current
=
[
s
for
s
in
Semester
.
objects
.
all
()
if
s
.
is_on
(
n
)]
created_by
=
models
.
ForeignKey
(
'Person'
,
related_name
=
'created_marks'
)
try
:
created_at
=
models
.
DateTimeField
(
auto_now_add
=
True
)
return
current
[
0
]
modified_by
=
models
.
ForeignKey
(
'Person'
,
related_name
=
'modified_marks'
)
except
:
modified_at
=
models
.
DateTimeField
(
auto_now
=
True
)
raise
ValidationError
(
_
(
'There is no current semester.'
)
)
class
Attendance
(
models
.
Model
):
present
=
models
.
NullBooleanField
()
student
=
models
.
ForeignKey
(
'Person'
)
lesson
=
models
.
ForeignKey
(
'school.Lesson'
)
modified_by
=
models
.
ForeignKey
(
'Person'
,
related_name
=
'modified_attendances'
)
modified_at
=
models
.
DateTimeField
(
auto_now
=
True
)
class
LessonClass
(
models
.
Model
):
class
Group
(
models
.
Model
):
group
=
models
.
ForeignKey
(
'school.Group'
)
name
=
models
.
CharField
(
max_length
=
80
,
unique
=
True
)
course
=
models
.
ForeignKey
(
'Course'
,
null
=
True
,
blank
=
True
)
semester
=
models
.
ForeignKey
(
'Semester'
,
null
=
False
,
blank
=
False
)
owners
=
models
.
ManyToManyField
(
User
,
blank
=
True
,
null
=
True
,
related_name
=
'owned_groups'
)
members
=
models
.
ManyToManyField
(
User
,
blank
=
True
,
null
=
True
,
related_name
=
'course_groups'
)
class
Lesson
(
models
.
Model
):
class
Meta
:
lesson_class
=
models
.
ForeignKey
(
'school.LessonClass'
)
unique_together
=
((
'name'
,
'course'
,
'semester'
,
),
)
group
=
models
.
ForeignKey
(
'school.Group'
)
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