source: main/waeup.sirp/trunk/src/waeup/sirp/students/student.py @ 6697

Last change on this file since 6697 was 6695, checked in by Henrik Bettermann, 14 years ago

Add clearance_locked attribute and set True when a student is added.

Add clearance edit page for students.

Shorten page template names.

Rename Edit buttons for officers. Officers are managing and students are editing objects.

  • Property svn:keywords set to Id
File size: 2.9 KB
RevLine 
[6621]1## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
2## This program is free software; you can redistribute it and/or modify
3## it under the terms of the GNU General Public License as published by
4## the Free Software Foundation; either version 2 of the License, or
5## (at your option) any later version.
6##
7## This program is distributed in the hope that it will be useful,
8## but WITHOUT ANY WARRANTY; without even the implied warranty of
9## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
10## GNU General Public License for more details.
11##
12## You should have received a copy of the GNU General Public License
13## along with this program; if not, write to the Free Software
14## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15##
16"""
17Container for the various objects owned by students.
18"""
19import grok
20from grok import index
[6652]21from zope.component.interfaces import IFactory, ComponentLookupError
[6621]22from zope.interface import implementedBy
[6637]23from hurry.workflow.interfaces import IWorkflowInfo, IWorkflowState
24from waeup.sirp.interfaces import IObjectHistory
[6694]25from waeup.sirp.students.interfaces import (
[6695]26    IStudent, IStudentNavigation, IStudentBaseEdit, IStudentClearanceEdit,
27    IStudentPersonalEdit)
[6621]28from waeup.sirp.utils.helpers import attrs_to_fields
[6651]29from waeup.sirp.students.utils import generate_student_id
[6621]30
31class Student(grok.Container):
32    """This is a student container for the various objects
33    owned by students.
34    """
[6694]35    grok.implements(IStudent, IStudentNavigation,
[6695]36        IStudentBaseEdit, IStudentClearanceEdit, IStudentPersonalEdit)
[6621]37    grok.provides(IStudent)
38
39    def __init__(self):
40        super(Student, self).__init__()
[6637]41        IWorkflowInfo(self).fireTransition('create')
[6652]42        # The catalog doesn't exist in unit tests
43        try:
44            self.student_id = generate_student_id('?')
45        except ComponentLookupError:
[6666]46            self.student_id = u'Z654321'
[6621]47        return
48
[6637]49    def loggerInfo(self, ob_class, comment=None):
50        target = self.__name__
51        return grok.getSite()['students'].logger_info(ob_class,target,comment)
52
53    @property
54    def state(self):
55        state = IWorkflowState(self).getState()
56        return state
57
58    @property
59    def history(self):
60        history = IObjectHistory(self)
61        return history
62
[6642]63    def getStudent(self):
64        return self
65
[6621]66# Set all attributes of Student required in IStudent as field
67# properties. Doing this, we do not have to set initial attributes
68# ourselves and as a bonus we get free validation when an attribute is
69# set.
70Student = attrs_to_fields(Student)
71
72class StudentFactory(grok.GlobalUtility):
73    """A factory for students.
74    """
75    grok.implements(IFactory)
76    grok.name(u'waeup.Student')
77    title = u"Create a new student.",
78    description = u"This factory instantiates new student instances."
79
80    def __call__(self, *args, **kw):
81        return Student()
82
83    def getInterfaces(self):
84        return implementedBy(Student)
Note: See TracBrowser for help on using the repository browser.