Changeset 10634


Ignore:
Timestamp:
21 Sep 2013, 08:27:47 (11 years ago)
Author:
Henrik Bettermann
Message:

Disable score editing on department manage page.

Add tests.

Location:
main/waeup.kofa/trunk/src/waeup/kofa
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_browser.py

    r10435 r10634  
    116116        # The code has explicitely to be set, otherwise we don't
    117117        # find created students in their department
    118         self.app['faculties']['fac1']['dep1'] = Department(code='dep1')
     118        self.app['faculties']['fac1']['dep1'] = Department(code=u'dep1')
    119119        self.department = self.app['faculties']['fac1']['dep1']
    120120        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
  • main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_browser.py

    r10458 r10634  
    7171        self.certificate.school_fee_2 = 20000.0
    7272        self.app['faculties']['fac1'] = Faculty(code='fac1')
    73         self.app['faculties']['fac1']['dep1'] = Department(code='dep1')
     73        self.app['faculties']['fac1']['dep1'] = Department(code=u'dep1')
    7474        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
    7575            self.certificate)
  • main/waeup.kofa/trunk/src/waeup/kofa/students/browser.py

    r10632 r10634  
    30713071        self.current_academic_session = grok.getSite()[
    30723072            'configuration'].current_academic_session
     3073        if self.context.__parent__.__parent__.score_editing_disabled:
     3074            self.flash(_('Score editing disabled.'))
     3075            self.redirect(self.url(self.context))
     3076            return
    30733077        if not self.current_academic_session:
    30743078            self.flash(_('Current academic session not set.'))
  • main/waeup.kofa/trunk/src/waeup/kofa/students/reports/tests/test_student_statistics.py

    r10574 r10634  
    4949    def test_get_student_stats_session_multiple(self):
    5050        # we can get a table with several students
    51         self.create_cert('fac2', 'dept2', 'CERT2')
     51        self.create_cert(u'fac2', u'dept2', u'CERT2')
    5252        result1 = get_student_stats(2010, 'Undergraduate Full-Time')
    5353        result2 = get_student_stats(2009, 'Undergraduate Full-Time')
     
    6969
    7070    def test_create_pdf(self):
    71         self.create_cert('FAC2', 'dept2', 'CERT2')
     71        self.create_cert(u'FAC2', u'dept2', u'CERT2')
    7272        report = StudentStatisticsReport(2010, 'Undergraduate Full-Time')
    7373        result = report.create_pdf()
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_browser.py

    r10598 r10634  
    16831683            self.student['studycourse']['100']['COURSE1'].course,
    16841684            self.course)
    1685         # Lecturer can neither access ths student ...
     1685        # Lecturer can neither access the student ...
    16861686        self.assertRaises(
    16871687            Unauthorized, self.browser.open, self.student_path)
    1688         # ... nor the respective course ticket since a
     1688        # ... nor the respective course ticket since
    16891689        # editing course tickets by lecturers is not feasible.
    1690         # Course results must be imported.
    16911690        self.assertTrue('COURSE1' in self.student['studycourse']['100'].keys())
    16921691        course_ticket_path = self.student_path + '/studycourse/100/COURSE1'
    16931692        self.assertRaises(
    16941693            Unauthorized, self.browser.open, course_ticket_path)
     1694        # Course results can be batch edited via the edit_courses view
     1695        self.app['faculties']['fac1']['dep1'].score_editing_disabled = True
     1696        self.browser.open("http://localhost/app/faculties/fac1/dep1/courses/COURSE1")
     1697        self.browser.getLink("Update scores").click()
     1698        self.assertTrue('Score editing disabled' in self.browser.contents)
     1699        self.app['faculties']['fac1']['dep1'].score_editing_disabled = False
     1700        self.browser.getLink("Update scores").click()
     1701        self.assertTrue('Current academic session not set' in self.browser.contents)
     1702        self.app['configuration'].current_academic_session = 2004
     1703        self.browser.getLink("Update scores").click()
     1704        self.assertFalse(
     1705            '<input type="text" name="scores" class="span1" />'
     1706            in self.browser.contents)
     1707        IWorkflowState(self.student).setState('courses validated')
     1708        # Student must be in state 'courses validated'
     1709        self.browser.open(
     1710            "http://localhost/app/faculties/fac1/dep1/courses/COURSE1/edit_scores")
     1711        self.assertTrue(
     1712            '<input type="text" name="scores" class="span1" />'
     1713            in self.browser.contents)
     1714        self.browser.getControl(name="scores", index=0).value = '55'
     1715        self.browser.getControl("Update scores").click()
     1716        # New score has been set
     1717        self.assertEqual(
     1718            self.student['studycourse']['100']['COURSE1'].score, 55)
     1719        # Score editing has been logged
     1720        logfile = os.path.join(
     1721            self.app['datacenter'].storage, 'logs', 'students.log')
     1722        logcontent = open(logfile).read()
     1723        self.assertTrue('mrslecturer - students.browser.EditScoresPage - '
     1724                        'K1000000 100/COURSE1 score updated (55)' in logcontent)
    16951725
    16961726    def test_change_current_mode(self):
  • main/waeup.kofa/trunk/src/waeup/kofa/students/tests/test_move.py

    r9341 r10634  
    3131            self.app['faculties']['fac1']['dep1'].certificates['CERT1'],
    3232            self.certificate)
    33         self.app['faculties']['fac1']['dep2'] = Department(code='dep2')
     33        self.app['faculties']['fac1']['dep2'] = Department(code=u'dep2')
    3434        self.certificate.moveCertificate('fac1', 'dep2')
    3535        self.assertEqual(
  • main/waeup.kofa/trunk/src/waeup/kofa/university/department.py

    r10561 r10634  
    2828from waeup.kofa.utils.batching import VirtualExportJobContainer
    2929from waeup.kofa.interfaces import IKofaUtils
     30from waeup.kofa.utils.helpers import attrs_to_fields
    3031from waeup.kofa.university.interfaces import IDepartment, IDepartmentAdd
    3132
     
    8990        return longtitle(self)
    9091
     92# Set all attributes of Department required in IDepartment as field
     93# properties. Doing this, we do not have to set initial attributes
     94# ourselves and as a bonus we get free validation when an attribute is
     95# set.
     96Department = attrs_to_fields(Department)
     97
    9198class DepartmentFactory(grok.GlobalUtility):
    9299    """A factory for department containers.
  • main/waeup.kofa/trunk/src/waeup/kofa/university/interfaces.py

    r10185 r10634  
    103103        )
    104104
     105    score_editing_disabled = schema.Bool(
     106        title = _(u'Score editing disabled'),
     107        description = _(
     108            u'Lectures cannnot edit scores if ticked.'),
     109        required = False,
     110        default = False,
     111        )
     112
    105113    courses = Attribute("A container for courses.")
    106114    certificates = Attribute("A container for certificates.")
Note: See TracChangeset for help on using the changeset viewer.