示例#1
0
def manage(request):
    user = request.session.get('User')
    if (user == None):
        return view.alert(request, 'Please login!')

    user = User.objects.get(id=user['id'])

    if (user.isCaptain == False):
        return view.alert(request, 'You are not a captain.')

    context = {'team': user.team}

    #通过入队申请
    if (request.POST and request.POST.get('accept')):
        candidate = User.objects.get(id=request.POST.get('accept'))
        if (candidate and candidate.team == user.team
                and candidate.isMember == False):
            candidate.isMember = True
            candidate.save()

    candidateList = User.objects.filter(team=user.team, isMember=False)
    context['candidateList'] = []
    for candidate in candidateList:
        context['candidateList'].append(json.loads(candidate.information))
    return view.mainStyle(request, 'team/manage.html', context)
示例#2
0
文件: notice.py 项目: urkax/FC17
def create(request):
	user = request.session.get('User')
	if (user == None):
		return view.alert(request, 'Please login!')
	else:
		user = User.objects.get(id = user['id'])
		if (user == None or user.adminLevel == 0):
			return view.alert(request, 'Your level is not enough!')
	
	if (request.POST and request.POST.get('title') and request.POST.get('content')):
		result, tips = tools.createNotice(user, request.POST['title'], request.POST['content'])
		return view.alert(request, tips)
		
	return view.mainStyle(request, 'notice/create.html')
示例#3
0
def detail(request, teamID=None):
    user = request.session.get('User')
    if (user != None):
        user = User.objects.get(id=user['id'])

    if (teamID):
        team = Team.objects.get(id=teamID)
        if (team == None):
            return view.alert("Team doesn't exist")
        if (user and request.POST):
            if (user.isMember == 0 and request.POST.get('action') == 'Join'):
                user.team = team
                user.save()
            elif team == user.team:
                if (user.isCaptain == 0
                        and request.POST.get('action') == 'Exit'):
                    user.team = None
                    user.isMember = 0
                    user.save()
                elif (user.isCaptain == 1
                      and request.POST.get('action') == 'Disband'):
                    tools.disbandTeam(team)
                    return redirect("/team/")
    else:
        if (user == None):
            return view.alert(request, 'Please login!')

        if (user.isMember == False):
            return create(request)
        else:
            team = user.team

    context = {'team': team}
    memberList = []
    members = User.objects.filter(team=team, isMember=True)

    for member in members:
        if member.isCaptain:
            captain = json.loads(member.information)
        else:
            memberList.append(json.loads(member.information))
    context['members'] = memberList
    context['captain'] = captain
    context['user'] = user
    return view.mainStyle(request, 'team/detail.html', context)
示例#4
0
def create(request):
    user = request.session.get('User')
    if (user == None):
        return view.alert(request, 'Please login!')

    context = {}
    if (request.POST and request.POST.get('name')
            and request.POST.get('introduction')):
        result, tips = tools.createTeam(user['id'], request.POST['name'],
                                        request.POST['introduction'])
        #result 为True/False表示是否创建成功,tips为相应提示
        context['result'] = result
        context['tips'] = tips
        return detail(request)
    return view.mainStyle(request, 'team/create.html', context)
示例#5
0
文件: notice.py 项目: urkax/FC17
def detail(request, noticeID):
	user = request.session.get('User')
	notice = Notice.objects.get(id = noticeID)
	
	context = {'notice' : notice}
	
	if (notice == None):
		return view.alert("The notice doesn't exist.")
	
	if (request.POST and request.POST.get('comment') and user):
		result, tips = tools.submitComment(user['id'], request.POST['comment'], notice)
		context['result'] = result
		context['tips'] = tips
	
	
	commentList = Comment.objects.filter(notice = notice)
	commentListWithUser = []
	for comment in commentList:
		commentListWithUser.append({'comment' : comment, 'user' : json.loads(comment.user.information)})
	context['commentList'] = commentListWithUser
	return view.mainStyle(request, 'notice/detail.html', context)