Пример #1
0
Файл: views.py Проект: YLAsce/oj
def modifyTeamMember(request, cid):
    logger.info(unicode(request).replace("\n", "\t"))
    cid = int(cid)
    try:
        team = Team.getSessionTeam(request.session)
    except Exception as e:
        request.session["team_id"] = None
        messages.add_message(request, messages.INFO, u"请先登录!")
        return redirect("Register:team_login")

    try:
        contestant = Contestant.getById(cid)
        belong_team = contestant.team
        if team.pk != belong_team.pk:
            raise Exception(u"您没有查看该队伍信息的权限!")

        if request.method != "POST":
            return render(
                request,
                "newtpl/register/modify_member.html",
                {
                    "gender_choices": Const.GENDER_CHOICES,
                    "school_choices": Const.SCHOOL_CHOICES,
                    "grade_choices": Const.GRADE_CHOICES,
                    "contestant": contestant,
                },
            )

        form = ContestantForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data["name"]
            gender = form.cleaned_data["gender"]
            email = form.cleaned_data["email"]
            grade = form.cleaned_data["grade"]
            mobile = form.cleaned_data["mobile"]
            student_id = form.cleaned_data["student_id"]
            class_id = form.cleaned_data["class_id"]
            school = form.cleaned_data["school"]
            contestant.modifyContestant(name, gender, grade, email, mobile, student_id, class_id, school, belong_team)
        else:
            raise Exception(u"输入的内容不合法!")

        # Success
        messages.add_message(request, messages.SUCCESS, u"修改队员%s成功!请等待管理员审核" % name)
        belong_team.updateStatus("Pending")
        return redirect("Register:team_info", belong_team.pk)
    except Exception as e:
        logger.error(unicode(e).replace("\n", "\t"))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect("Register:modify_member", cid)
Пример #2
0
def addTeamMember(request, tid):
    logger.info(unicode(request).replace('\n', '\t'))
    tid = int(tid)
    try:
        team = Team.getSessionTeam(request.session)
    except Exception as e:
        request.session['team_id'] = None
        messages.add_message(request, messages.INFO, u'请先登录!')
        return redirect('Register:team_login')

    try:
        if team.pk != tid:
            raise Exception(u'您没有查看该队员信息的权限!')
        
        target_team = Team.getById(tid)
        if request.method != 'POST':
            return render(request, 'newtpl/register/add_member.html', {'target_team': target_team, 'gender_choices': Const.GENDER_CHOICES, 'school_choices': Const.SCHOOL_CHOICES, 'grade_choices': Const.GRADE_CHOICES})

        form = ContestantForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            gender = form.cleaned_data['gender']
            email = form.cleaned_data['email']
            grade = form.cleaned_data['grade']
            mobile = form.cleaned_data['mobile']
            student_id = form.cleaned_data['student_id']
            class_id = form.cleaned_data['class_id']
            school = form.cleaned_data['school']
            info = form.cleaned_data['info']
            Contestant.addContestant(name, gender, grade, email, mobile, student_id, class_id, school, info, target_team)
        else:
            raise Exception(u'输入信息不合法!')

        # Success
        messages.add_message(request, messages.SUCCESS, u'完善信息成功!请等待管理员审核')
        target_team.status = '等待审核'
        target_team.updateStatus('Pending')
        return redirect('Register:team_info', tid)
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect('Register:team_info', team.pk)
Пример #3
0
def modifyTeamMember(request, cid):
    logger.info(unicode(request).replace('\n', '\t'))
    cid = int(cid)
    try:
        team = Team.getSessionTeam(request.session)
    except Exception as e:
        request.session['team_id'] = None
        messages.add_message(request, messages.INFO, u'请先登录!')
        return redirect('Register:team_login')

    try:
        contestant = Contestant.getById(cid)
        belong_team = contestant.team
        if team.pk != belong_team.pk:
            raise Exception(u'您没有查看该队员信息的权限!')
        
        if request.method != 'POST':
            return render(request, 'newtpl/register/modify_member.html', {'gender_choices': Const.GENDER_CHOICES, 'school_choices': Const.SCHOOL_CHOICES, 'grade_choices': Const.GRADE_CHOICES, 'contestant': contestant})

        form = ContestantForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            gender = form.cleaned_data['gender']
            email = form.cleaned_data['email']
            grade = form.cleaned_data['grade']
            mobile = form.cleaned_data['mobile']
            student_id = form.cleaned_data['student_id']
            class_id = form.cleaned_data['class_id']
            school = form.cleaned_data['school']
            info = form.cleaned_data['info']
            contestant.modifyContestant(name, gender, grade, email, mobile, student_id, class_id, school, info, belong_team)
        else:
            raise Exception(u'输入的内容不合法!')

        # Success
        messages.add_message(request, messages.SUCCESS, u'修改队员信息%s成功!请等待管理员审核' % name)
        belong_team.updateStatus('Pending')
        return redirect('Register:team_info', belong_team.pk)
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect('Register:modify_member', cid)
Пример #4
0
Файл: views.py Проект: YLAsce/oj
def addTeamMember(request, tid):
    logger.info(unicode(request).replace('\n', '\t'))
    tid = int(tid)
    try:
        team = Team.getSessionTeam(request.session)
    except Exception as e:
        request.session['team_id'] = None
        messages.add_message(request, messages.INFO, u'请先登录!')
        return redirect('Register:team_login')

    try:
        if team.pk != tid:
            raise Exception(u'您没有查看该队伍信息的权限!')
        
        target_team = Team.getById(tid)
        if request.method != 'POST':
            return render(request, 'newtpl/register/add_member.html', {'target_team': target_team, 'gender_choices': Const.GENDER_CHOICES, 'school_choices': Const.SCHOOL_CHOICES, 'grade_choices': Const.GRADE_CHOICES})

        form = ContestantForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            gender = form.cleaned_data['gender']
            email = form.cleaned_data['email']
            grade = form.cleaned_data['grade']
            mobile = form.cleaned_data['mobile']
            student_id = form.cleaned_data['student_id']
            class_id = form.cleaned_data['class_id']
            school = form.cleaned_data['school']
            Contestant.addContestant(name, gender, grade, email, mobile, student_id, class_id, school, target_team)
        else:
            raise Exception(u'输入的内容不合法!')

        # Success
        messages.add_message(request, messages.SUCCESS, u'添加队员%s成功!请等待管理员审核' % name)
        target_team.status = '等待审核'
        target_team.updateStatus('Pending')
        return redirect('Register:team_info', tid)
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect('Register:team_info', team.pk)
Пример #5
0
Файл: views.py Проект: YLAsce/oj
def modifyTeamMember(request, cid):
    logger.info(unicode(request).replace('\n', '\t'))
    cid = int(cid)
    try:
        team = Team.getSessionTeam(request.session)
    except Exception as e:
        request.session['team_id'] = None
        messages.add_message(request, messages.INFO, u'请先登录!')
        return redirect('Register:team_login')

    try:
        contestant = Contestant.getById(cid)
        belong_team = contestant.team
        if team.pk != belong_team.pk:
            raise Exception(u'您没有查看该队伍信息的权限!')
        
        if request.method != 'POST':
            return render(request, 'newtpl/fresh/modify_member.html', {'gender_choices': Const.GENDER_CHOICES, 'school_choices': Const.SCHOOL_CHOICES, 'grade_choices': Const.GRADE_CHOICES, 'contestant': contestant})

        form = ContestantForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            gender = form.cleaned_data['gender']
            email = form.cleaned_data['email']
            grade = form.cleaned_data['grade']
            mobile = form.cleaned_data['mobile']
            student_id = form.cleaned_data['student_id']
            class_id = form.cleaned_data['class_id']
            school = form.cleaned_data['school']
            contestant.modifyContestant(name, gender, grade, email, mobile, student_id, class_id, school, belong_team)
        else:
            raise Exception(u'输入的内容不合法!')

        # Success
        messages.add_message(request, messages.SUCCESS, u'修改队员%s成功!请等待管理员审核' % name)
        belong_team.updateStatus('Pending')
        return redirect('Register:team_info', belong_team.pk)
    except Exception as e:
        logger.error(unicode(e).replace('\n', '\t'))
        messages.add_message(request, messages.INFO, unicode(e))
        return redirect('Register:modify_member', cid)