## $Id: utils.py 17869 2024-08-02 19:38:16Z henrik $
##
## Copyright (C) 2011 Uli Fouquet & Henrik Bettermann
## This program is free software; you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation; either version 2 of the License, or
## (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##
import grok
from zope.component import getUtility
from waeup.kofa.interfaces import IExtFileStore
from waeup.kofa.students.utils import StudentsUtils
from kofacustom.nigeria.interfaces import MessageFactory as _

class NigeriaStudentsUtils(StudentsUtils):
    """A collection of customized methods.

    """

    SEPARATORS_DICT = {
        'form.fst_sit_fname': _(u'First Sitting Record'),
        'form.scd_sit_fname': _(u'Second Sitting Record'),
        'form.alr_fname': _(u'Advanced Level Record'),
        'form.hq_type': _(u'Higher Education Record'),
        'form.hq2_type': _(u'Second Higher Education Record'),
        'form.nysc_year': _(u'NYSC Information'),
        'form.employer': _(u'Employment History'),
        'form.former_matric': _(u'Former Student'),
        }

    STUDENT_EXPORTER_NAMES = StudentsUtils().STUDENT_EXPORTER_NAMES + (
            'clearancerequested',)

    # Maximum size of upload files in kB
    MAX_KB = 250

    def allowPortraitChange(self, student):
        """Check if student is allowed to change the portrait file.
        """
        # Passport pictures must not be editable if application slip
        # exists. Students are not allowed to change the picture if they passed
        # the regular Kofa application.
        slip = getUtility(IExtFileStore).getFileByContext(
            student, 'application_slip')
        if student.state not in self.PORTRAIT_CHANGE_STATES or slip is not None:
            return False
        return True

    def final_clearance_enabled(self, student):
        if 'Test' in student.display_fullname:
            return True
        return False

