## $Id: pages.py 12234 2014-12-14 21:48:41Z 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 waeup.kofa.browser.pages import (
    SessionConfigurationAddFormPage, SessionConfigurationManageFormPage,
    LoginPage, CertificatePage, CertificateManageFormPage, DepartmentPage,
    DepartmentManageFormPage, CertificateAddFormPage, DepartmentAddFormPage,
    FacultyManageFormPage, FacultyAddFormPage, LoginPage,
    DatacenterImportStep2,
    DatacenterUploadPage)
from waeup.kofa.university.interfaces import ICertificate
from kofacustom.pcn.interfaces import (
    ICustomSessionConfiguration, ICustomSessionConfigurationAdd)

from kofacustom.pcn.university.faculty import ICustomDepartment, ICustomFaculty

grok.templatedir('templates')

class CustomSessionConfigurationAddFormPage(SessionConfigurationAddFormPage):
    """Add a session configuration object to configuration container.
    """
    form_fields = grok.AutoFields(ICustomSessionConfigurationAdd)

class CustomSessionConfigurationManageFormPage(SessionConfigurationManageFormPage):
    """Manage session configuration object.
    """
    form_fields = grok.AutoFields(ICustomSessionConfiguration)


class FacultyAddFormPage(FacultyAddFormPage):
    """ Page form to add a new faculty to a faculty container.
    """
    form_fields = grok.AutoFields(ICustomFaculty)

class FacultyManageFormPage(FacultyManageFormPage):
    """Manage the basic properties of a `Faculty` instance.
    """
    form_fields = grok.AutoFields(ICustomFaculty).omit('code')

class DepartmentPage(DepartmentPage):
    """Department index page.
    """

class DepartmentManageFormPage(DepartmentManageFormPage):
    """Department index page.
    """
    grok.template('departmentmanagepage')
    form_fields = grok.AutoFields(ICustomDepartment).omit(
        'code', 'score_editing_disabled')

class DepartmentAddFormPage(DepartmentAddFormPage):
    """Department index page.
    """
    form_fields = grok.AutoFields(ICustomDepartment).omit('score_editing_disabled')

class CertificatePage(CertificatePage):
    """Index page for certificates.
    """
    grok.template('certificatepage')

    form_fields = grok.AutoFields(ICertificate).omit(
        'study_mode', 'start_level', 'end_level', 'school_fee_2',
        'school_fee_3', 'school_fee_4', 'ratio')

class CertificateManageFormPage(CertificateManageFormPage):
    """Manage the properties of a `Certificate` instance.
    """
    grok.template('certificatemanagepage')

    form_fields = grok.AutoFields(ICertificate).omit(
        'code', 'study_mode', 'start_level', 'end_level', 'school_fee_2',
        'school_fee_3', 'school_fee_4', 'ratio')

class CertificateAddFormPage(CertificateAddFormPage):
    """Add-form to add certificate to a department.
    """
    form_fields = grok.AutoFields(ICertificate).omit(
        'study_mode', 'start_level', 'end_level', 'school_fee_2',
        'school_fee_3', 'school_fee_4', 'ratio')

class LoginPage(LoginPage):
    """A login page, available for all objects.
    """

class DatacenterUploadPage(DatacenterUploadPage):

    def getImporters(self):
        importer_props = super(DatacenterUploadPage, self).getImporters()
        filtered = [ip for ip in importer_props if ip['name'] in
            ('facultyprocessor', 'departmentprocessor',)]
        return filtered

class DatacenterImportStep2(DatacenterImportStep2):

    def getImporters(self):
        importers = super(DatacenterImportStep2, self).getImporters()
        filtered = [i for i in importers if i['name'] in
            ('facultyprocessor', 'departmentprocessor',)]
        return filtered