예제 #1
0
def removeStudent(request):
    student_id = int(request.matchdict['student_id'])
    ls = request.db.query(models.LectureStudent).get(
        (request.context.lecture.id, student_id))
    if not ls:
        request.session.flash('Student in Vorlesung nicht gefunden!',
                              queue='errors')
    else:
        lrs = models.LectureRemovedStudent()
        lrs.student_id = student_id
        lrs.lecture_id = ls.lecture_id
        lrs.tutorial_id = ls.tutorial_id
        request.db.add(lrs)
        request.db.delete(ls)
        request.db.commit()
        request.session.flash(u'Student aus Übungsgruppe ausgetragen!',
                              queue='messages')
    if request.referrer:
        return HTTPFound(location=request.referrer)
    else:
        return HTTPFound(location=request.route_url('start'))
예제 #2
0
def unsubscribe(request):
    tutorials = request.context.tutorials
    tutorial = tutorials[0]
    lecture = tutorial.lecture
    ls = request.db.query(models.LectureStudent).get(
        (lecture.id, request.user.id))
    if not ls or ls.tutorial_id != tutorial.id:
        return HTTPForbidden(
            'Sie sind zu dieser Übungsgruppe nicht angemeldet')
    lrs = request.db.query(models.LectureRemovedStudent).get(
        (lecture.id, request.user.id))
    if not lrs:
        lrs = models.LectureRemovedStudent()
        lrs.lecture = lecture
        lrs.student = request.user
    lrs.tutorial = tutorial
    if not lrs in request.db: request.db.add(lrs)
    request.db.delete(ls)
    request.db.commit()
    sendChangesMailUnsubscribe(request, tutorial, request.user)
    request.session.flash(u'Erfolgreich aus Übungsgruppe ausgetragen',
                          queue='messages')
    return HTTPFound(location=request.route_url('start'))
예제 #3
0
def unsubscribe(context=None, request=None, tutorial=None, user=None, db=None):
    tutorial = request.context.tutorials[0] if tutorial is None else tutorial
    user = request.user if user is None else user
    db = request.db if db is None else db
    lecture = tutorial.lecture
    ls = db.query(models.LectureStudent).get((lecture.id, user.id))
    if not ls or ls.tutorial_id != tutorial.id:
        return HTTPForbidden(
            'Sie sind zu dieser Übungsgruppe nicht angemeldet')
    lrs = db.query(models.LectureRemovedStudent).get((lecture.id, user.id))
    if not lrs:
        lrs = models.LectureRemovedStudent()
        lrs.lecture = lecture
        lrs.student = user
    lrs.tutorial = tutorial
    if not lrs in db: db.add(lrs)
    db.delete(ls)
    db.commit()
    if request is not None:
        sendChangesMailUnsubscribe(request, tutorial, user)
        request.session.flash('Erfolgreich aus Übungsgruppe ausgetragen',
                              queue='messages')
        return HTTPFound(location=request.route_url('overview'))