Exemple #1
0
 def delete(self, id):
     """DELETE /substitutions/id: Delete an existing item"""
     # Forms posted to this method should contain a hidden field:
     #    <input type="hidden" name="_method" value="DELETE" />
     # Or using helpers:
     #    h.form(url('substitution', id=ID),
     #           method='delete')
     # url('substitution', id=ID)
     s = Session.query(Substitution).get(id)
     Session.delete(s)
     Session.commit()
     redirect(url('substitutions'))
Exemple #2
0
 def delete(self, id):
     """DELETE /substitutions/id: Delete an existing item"""
     # Forms posted to this method should contain a hidden field:
     #    <input type="hidden" name="_method" value="DELETE" />
     # Or using helpers:
     #    h.form(url('substitution', id=ID),
     #           method='delete')
     # url('substitution', id=ID)
     s = Session.query(Substitution).get(id)
     Session.delete(s)
     Session.commit()
     redirect(url('substitutions'))
Exemple #3
0
    def create(self):
        """POST /substitutions: Create a new item"""
        # url('substitutions')
        date = datetime.datetime.strptime(request.params['date'], '%Y-%m-%d')
        order = int(request.params['order'])
        group = Session.query(Group).get(int(request.params['group']))
        part = int(request.params['part'])
        raw_educator = request.params['educator']
        if raw_educator == 0:
            teacher = None
        else:
            teacher = Session.query(Educator).get(raw_educator)
        comment = request.params['comment']

        s = Substitution(date, order, group, teacher, part, comment)
        Session.add(s)
        Session.commit()
        redirect(url('substitutions'))
Exemple #4
0
    def create(self):
        """POST /substitutions: Create a new item"""
        # url('substitutions')
        date = datetime.datetime.strptime(request.params['date'], '%Y-%m-%d')
        order = int(request.params['order'])
        group = Session.query(Group).get(int(request.params['group']))
        part = int(request.params['part'])
        raw_educator = request.params['educator']
        if raw_educator == 0:
            teacher = None
        else:
            teacher = Session.query(Educator).get(raw_educator)
        comment = request.params['comment']

        s = Substitution(date, order, group, teacher, part, comment)
        Session.add(s)
        Session.commit()
        redirect(url('substitutions'))
Exemple #5
0
    def add(self):
        form_numbers = self.form_result['lucky']
        numbers = []
        for lucky in form_numbers:
            if lucky['date'] and lucky['number']:
                ln = LuckyNumber(lucky['date'], lucky['number'])
                numbers.append(ln)

        Session.add_all(numbers)

        try:
            Session.commit()
        except IntegrityError as e:
            session['flash'] = 'There is already lucky number for %s' % e.params[0]
            session.save()
            return redirect(url('lucky_add'))
        else:
            if len(numbers) == 0:
                session['flash'] = 'No lucky number has been added!'
            else:
                session['flash'] = 'Lucky numbers have been added!'
            session.save()
            return redirect(url('lucky_home'))