source: main/waeup.sirp/trunk/src/waeup/sirp/applicants/container.py @ 7247

Last change on this file since 7247 was 7240, checked in by Henrik Bettermann, 13 years ago

Rebuild applicants package (1st part). Applicants now have an applicant_id and a password and can use the regular login page to enter the portal.

Add user_type attribute to SIRPPrincipal objects.

Add some permissions in students package.

Some tests are still missing and will be re-added soon.

  • Property svn:keywords set to Id
File size: 3.8 KB
RevLine 
[5649]1## $Id: container.py 7240 2011-11-30 23:13:26Z henrik $
[6077]2##
[6478]3## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
[5649]4## This program is free software; you can redistribute it and/or modify
5## it under the terms of the GNU General Public License as published by
6## the Free Software Foundation; either version 2 of the License, or
7## (at your option) any later version.
[6077]8##
[5649]9## This program is distributed in the hope that it will be useful,
10## but WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12## GNU General Public License for more details.
[6077]13##
[5649]14## You should have received a copy of the GNU General Public License
15## along with this program; if not, write to the Free Software
16## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17##
18"""
[5676]19Containers for university applicants.
[5649]20"""
21import grok
[6280]22from zope.component.factory import Factory
23from zope.component.interfaces import IFactory
[5821]24from waeup.sirp.applicants.interfaces import (
[6069]25    IApplicantsContainer, IApplicantsContainerAdd,
[7240]26    IApplicantsContainerProvider, IApplicant
[5821]27    )
[6072]28from waeup.sirp.utils.helpers import attrs_to_fields
[5649]29
[5676]30class ApplicantsContainer(grok.Container):
31    """An applicants container contains university applicants.
[5649]32    """
[6069]33    grok.implements(IApplicantsContainer,IApplicantsContainerAdd)
[5649]34
[6074]35    #: These are 'class-attributes'. Do not fiddle around with it in
36    #: instances of this class.
37    #:
38    #: The title of this container as displayed in add-forms. It should
39    #: give some idea about what kind of container this is (one or two words)
40    container_title = u'Basic'
41
42    #: Another 'class-attribute'. Do not fiddle around with it in instances
43    #: of this class.
44    #:
45    #: The `container_description` gives a short explanation about for what
46    #: purposes this container type serves (a few words only).
47    container_description = u'handles basic applicants'
[6077]48
[6184]49    @property
50    def local_roles(cls):
[7182]51        return []
[6184]52
[5649]53    def archive(self, app_ids=None):
[5676]54        """Create on-dist archive of applicants stored in this term.
[5649]55
[5676]56        If app_ids is `None`, all applicants are archived.
[5649]57
58        If app_ids contains a single id string, only the respective
[5676]59        applicants are archived.
[5649]60
61        If app_ids contains a list of id strings all of the respective
[5676]62        applicants types are saved to disk.
[5649]63        """
[6601]64        raise NotImplementedError()
[5649]65
66    def clear(self, app_ids=None, archive=True):
[5676]67        """Remove applicants of type given by 'id'.
[5649]68
[5676]69        Optionally archive the applicants.
[6077]70
[5676]71        If id is `None`, all applicants are archived.
[5649]72
73        If id contains a single id string, only the respective
[5676]74        applicants are archived.
[5649]75
76        If id contains a list of id strings all of the respective
[5676]77        applicant types are saved to disk.
[5649]78
79        If `archive` is ``False`` none of the archive-handling is done
[5676]80        and respective applicants are simply removed from the
[5649]81        database.
82        """
[6601]83        raise NotImplementedError()
[6072]84
[7240]85    def addApplicant(self, applicant):
86        """Add an applicant.
87        """
88        if not IApplicant.providedBy(applicant):
89            raise TypeError(
90                'ApplicantsContainers contain only IApplicant instances')
91        self[applicant.application_number] = applicant
92        return
93
[6072]94ApplicantsContainer = attrs_to_fields(ApplicantsContainer)
[6077]95
[5821]96class ApplicantsContainerProvider(grok.GlobalUtility):
97    """A utility that provides basic applicants containers.
98    """
[5846]99    grok.implements(IApplicantsContainerProvider)
[6070]100    grok.name('waeup.sirp.applicants.ApplicantsContainer')
[5821]101
[6074]102    #: The applicants container type this provider provides:
103    #: :class:`ApplicantsContainer`.
[5821]104    factory = ApplicantsContainer
[6280]105
106factory = Factory(lambda : ApplicantsContainer, 'ApplicantsContainer')
107grok.global_utility(factory, IFactory, name='waeup.ApplicantsContainer')
Note: See TracBrowser for help on using the repository browser.