Changeset 15932 for main


Ignore:
Timestamp:
16 Jan 2020, 11:04:43 (5 years ago)
Author:
Henrik Bettermann
Message:

Reset _curr_stud_id if student could not be created.

Location:
main/waeup.kofa/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/CHANGES.txt

    r15920 r15932  
    441.6.1.dev0 (unreleased)
    55=======================
     6
     7* Reset _curr_stud_id if student could not be created.
    68
    79* Add `TranscriptDataExporter` and reorganize exporter names.
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/applicant.py

    r15930 r15932  
    156156        and copy applicant data.
    157157        """
     158        site = grok.getSite()
    158159        # Is applicant in the correct state?
    159160        if self.state != 'admitted':
     
    164165            student.reg_number = self.reg_number
    165166        except RegNumNotInSource:
     167            # Reset _curr_stud_id
     168            site['students']._curr_stud_id -= 1
    166169            return False, _('Registration Number exists.')
    167170        # Has the course_admitted field been properly filled?
    168171        if self.course_admitted is None:
     172            # Reset _curr_stud_id
     173            site['students']._curr_stud_id -= 1
    169174            return False, _('No course admitted provided.')
    170175        # Set student attributes
     
    173178                setattr(student, item[1], getattr(self, item[0], None))
    174179        except RequiredMissing, err:
     180            site['students']._curr_stud_id -= 1
    175181            return False, 'RequiredMissing: %s' % err
    176182        except:
     183            site['students']._curr_stud_id -= 1
    177184            return False, 'Unknown Error'
    178185        # Prove if the certificate still exists
     
    180187            StudentStudyCourse().certificate = self.course_admitted
    181188        except ConstraintNotSatisfied, err:
     189            # Reset _curr_stud_id
     190            site['students']._curr_stud_id -= 1
    182191            return False, 'ConstraintNotSatisfied: %s' % self.course_admitted.code
    183192        # Finally prove if an application slip can be created
     
    186195                view=view)
    187196        except IOError:
     197            site['students']._curr_stud_id -= 1
    188198            return False, _('IOError: Application Slip could not be created.')
    189199        except LayoutError, err:
     200            site['students']._curr_stud_id -= 1
    190201            return False, _('Reportlab LayoutError: %s' % err)
    191202        except AttributeError, err:
     203            site['students']._curr_stud_id -= 1
    192204            return False, _('Reportlab AttributeError: ${a}', mapping = {'a':err})
    193205        except:
     206            site['students']._curr_stud_id -= 1
    194207            return False, _('Unknown Reportlab error')
    195208        # Add student
    196         site = grok.getSite()
    197209        site['students'].addStudent(student)
    198210        # Save student_id
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/browser.py

    r15833 r15932  
    700700    """Create all student objects from applicant data
    701701    in the root container or in a specific applicants container only.
    702     Only PortalManagers can do this.
     702    Only PortalManagers or StudentCreators can do this.
    703703    """
    704704    #grok.context(IApplicantsContainer)
  • main/waeup.kofa/trunk/src/waeup/kofa/applicants/tests/test_applicantcopier.py

    r15036 r15932  
    6363        fd = storage.getFile(file_id)
    6464        file_len_orig = len(fd.read())
     65        self.assertEqual(self.app['students']._curr_stud_id, 1000000)
    6566        # Let's try to create the student
    6667        (success, msg) = self.applicant.createStudent()
     
    6869        IWorkflowState(self.applicant).setState('admitted')
    6970        (success, msg) = self.applicant.createStudent()
     71        # Current student_id has not changed.
     72        self.assertEqual(self.app['students']._curr_stud_id, 1000000)
    7073        self.assertTrue(msg == 'No course admitted provided.')
    7174        self.browser.open(self.manage_path)
     
    7780        self.assertFalse(success)
    7881        self.assertTrue('ConstraintNotSatisfied: CERT1' in msg)
     82        # Current student_id has not changed.
     83        self.assertEqual(self.app['students']._curr_stud_id, 1000000)
    7984        # Ok, lets add the certificate and try again
    8085        self.app['faculties']['fac1']['dep1'].certificates.addCertificate(
     
    8590        (success, msg) = self.applicant.createStudent()
    8691        self.assertTrue('created' in msg)
     92        # Current student_id has not changed.
     93        self.assertEqual(self.app['students']._curr_stud_id, 1000001)
    8794        # The applicant is locked
    8895        self.assertTrue(self.applicant.locked)
     
    116123        self.assertTrue(len(pdf) > 0)
    117124        self.assertEqual(pdf[:8], '%PDF-1.4')
    118         # Copy te file to samples_dir
    119125        path = os.path.join(samples_dir(), 'application_slip.pdf')
    120126        open(path, 'wb').write(pdf)
Note: See TracChangeset for help on using the changeset viewer.