本文整理汇总了Python中utils.render_helper.render_index函数的典型用法代码示例。如果您正苦于以下问题:Python render_index函数的具体用法?Python render_index怎么用?Python render_index使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了render_index函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: edit
def edit(request, group_id):
group = get_group(group_id)
user_is_owner = has_group_ownership(request.user, group)
user_is_coowner = has_group_coownership(request.user, group)
if user_is_owner or user_is_coowner:
if request.method == 'GET':
group_dic = model_to_dict(group)
form = GroupFormEdit(initial=group_dic)
return render_index(
request, 'group/editGroup.html', {
'form': form,
'group': group,
'user_is_coowner': user_is_coowner,
})
if request.method == 'POST':
form = GroupFormEdit(request.POST, instance=group)
if form.is_valid():
modified_group = form.save()
message = 'Group %s modified!' % (modified_group.id)
messages.success(request, message)
logger.info('Group: Modified group %s!' % modified_group.id)
return HttpResponseRedirect(reverse('group:detail', kwargs={'group_id': modified_group.id}))
else:
return render_index(
request, 'group/editGroup.html', {
'form': form,
'user_is_coowner': user_is_coowner,
})
else:
raise PermissionDenied
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:30,代码来源:views.py
示例2: edit
def edit(request, cid):
try:
contest = Contest.objects.get(id=cid)
except Contest.DoesNotExist:
logger.warning("Contest: Can not edit contest %s! Contest not found!" % cid)
raise Http404("Contest does not exist, can not edit.")
title = "Edit Contest"
if can_edit_contest(request.user, contest):
contest_dic = model_to_dict(contest)
contest_dic["user"] = request.user
contest_dic["method"] = request.method
if request.method == "GET":
form = ContestForm(initial=contest_dic)
return render_index(request, "contest/editContest.html", {"form": form, "title": title, "contest": contest})
if request.method == "POST":
form = ContestForm(request.POST, instance=contest, initial={"method": request.method})
if form.is_valid():
modified_contest = form.save()
logger.info("Contest: User %s edited contest %s!" % (request.user, modified_contest.id))
message = 'Contest %s- "%s" edited!' % (modified_contest.id, modified_contest.cname)
messages.success(request, message)
return redirect("contest:contest", modified_contest.id)
else:
message = "Some fields are invalid!"
messages.error(request, message)
return render_index(
request, "contest/editContest.html", {"form": form, "title": title, "contest": contest}
)
raise PermissionDenied
开发者ID:jpdyuki,项目名称:NTHUOJ_web,代码行数:34,代码来源:views.py
示例3: edit_announce
def edit_announce(request, announce_id, group_id, redirect_page):
announce = get_announce(announce_id)
group = get_group(group_id)
user_is_owner = has_group_ownership(request.user, group)
user_is_coowner = has_group_coownership(request.user, group)
if user_is_owner or user_is_coowner:
if request.method == 'GET':
announce_dic = model_to_dict(announce)
form = AnnounceForm(initial=announce_dic)
return render_index(
request, 'group/editAnnounce.html', {
'form': form,
'group_id': group.id,
'announce_id': announce_id,
})
if request.method == 'POST':
form = AnnounceForm(request.POST, instance=announce)
if form.is_valid():
modified_announce = form.save()
logger.info(
'Announce: Announce %s has been changed!' % (announce.id))
if redirect_page == 'detail':
return HttpResponseRedirect(reverse('group:detail', kwargs={'group_id': group_id}))
else: # redirect_page=='viewall'
return HttpResponseRedirect(reverse('group:viewall_announce', kwargs={'group_id': group_id}))
else:
return render_index(
request, 'group/editAnnounce.html', {
'form': form,
})
else:
raise PermissionDenied
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:32,代码来源:announce.py
示例4: new
def new(request):
title = "New Contest"
if can_create_contest(request.user):
if request.method == 'GET':
form = ContestForm(initial=\
{'owner':request.user, 'user':request.user, 'method':request.method})
return render_index(request,'contest/editContest.html',
{'form':form,'title':title})
if request.method == 'POST':
form = ContestForm(request.POST, initial={'method':request.method})
if form.is_valid():
new_contest = form.save()
logger.info('Contest: User %s Create a new contest %s!' %
(request.user ,new_contest.id))
message = 'Contest %s- "%s" created!' % (new_contest.id, new_contest.cname)
messages.success(request, message)
return redirect('contest:contest', new_contest.id)
else:
message = 'Some fields are invalid!'
messages.error(request, message)
return render_index(request,'contest/editContest.html',
{'form':form,'title':title})
raise PermissionDenied
开发者ID:drowsy810301,项目名称:NTHUOJ_web,代码行数:27,代码来源:views.py
示例5: status
def status(request):
status_filter = StatusFilter(request.GET)
submissions = get_visible_submission(request.user).order_by('-id')
render_data = {}
render_data['status_filter'] = status_filter
render_data['running_contests'] = get_running_contests().order_by('id')
if status_filter.is_valid():
username = status_filter.cleaned_data['username']
cid = status_filter.cleaned_data['cid']
pid = status_filter.cleaned_data['pid']
status = status_filter.cleaned_data['status']
if username:
user = User.objects.get(username=username)
submissions = submissions.filter(user=user)
if pid:
problem = Problem.objects.get(id=pid)
submissions = submissions.filter(problem=problem)
if cid:
contest = Contest.objects.get(id=cid)
submissions = get_contest_submissions(contest, submissions)
if status:
submissions = submissions.filter(status=status)
submissions = get_current_page(request, submissions)
# Regroup submission details
submissions.object_list = regroup_submission(submissions.object_list)
# Serialize to json
if 'type' in request.GET and request.GET['type'] == 'json':
submissions = [submission['grouper']
for submission in submissions.object_list]
# Remove unnecessary fields
submissions = serialize("python", submissions)
submissions = [s['fields'] for s in submissions]
return HttpResponse(json.dumps(submissions, default=lambda obj: obj.isoformat() if hasattr(obj, 'isoformat') else obj))
else:
messages.warning(request, 'Please check filter constraints again!')
return render_index(request, 'status/status.html', render_data)
if not submissions:
messages.warning(request, 'No submissions found for the given query!')
render_data['submissions'] = submissions
return render_index(request, 'status/status.html', render_data)
开发者ID:LFsWang,项目名称:NTHUOJ_web,代码行数:52,代码来源:views.py
示例6: user_forget_password
def user_forget_password(request):
if request.user.is_authenticated():
return redirect(reverse('index:index'))
if request.method == 'POST':
user_form = UserForgetPasswordForm(data=request.POST)
if user_form.is_valid():
user = User.objects.get(username=user_form.cleaned_data['username'])
send_forget_password_email(request, user)
messages.success(request, 'Confirm email has sent to you.')
else:
return render_index(request, 'users/auth.html', {'form': user_form, 'title': 'Forget Password'})
return render_index(request, 'users/auth.html',
{'form': UserForgetPasswordForm(), 'title': 'Forget Password'})
开发者ID:bbiiggppiigg,项目名称:NTHUOJ_web,代码行数:14,代码来源:views.py
示例7: user_create
def user_create(request):
args = {}
args.update(csrf(request))
if request.method == 'POST':
user_form = UserCreationForm(request.POST)
args['user_form'] = user_form
if user_form.is_valid():
user = user_form.save()
send_activation_email(request, user)
user.backend = 'django.contrib.auth.backends.ModelBackend'
logger.info('user %s created' % str(user))
return redirect(reverse('index:alert', kwargs={'alert_info': 'mailbox'}))
else:
return render_index(request, 'users/auth.html', {'form': user_form, 'title': 'Sign Up'})
return render_index(request, 'users/auth.html', {'form': UserCreationForm(), 'title': 'Sign Up'})
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:15,代码来源:views.py
示例8: detail
def detail(request, group_id):
group = get_group(group_id)
show_number = 5; #number for brief list to show in group detail page.
all_contest = group.trace_contest.all()
annowence_list = group.announce.all()
student_list = group.member.order_by('user_level')
coowner_list = group.coowner.all()
owner = group.owner
user_is_owner = has_group_ownership(request.user, group)
running_contest_list = []
ended_contest_list = []
now = timezone.now()
for contest in all_contest:
if contest.start_time < now and contest.end_time > now:
running_contest_list.append(contest)
elif contest.end_time < now:
ended_contest_list.append(contest)
return render_index(
request, 'group/groupDetail.html', {
'rc_list': running_contest_list[0:show_number],
'ec_list': ended_contest_list[0:show_number],
'an_list': annowence_list,
'coowner_list': coowner_list,
'owner': owner,
's_list': student_list,
'group_name': group.gname,
'group_description': group.description,
'group_id': group.id,
'user_is_owner': user_is_owner,
})
开发者ID:drowsy810301,项目名称:NTHUOJ_web,代码行数:33,代码来源:views.py
示例9: detail
def detail(request, group_id):
group = get_group(group_id)
show_number = 5; #number for brief list to show in group detail page.
announce_list = group.announce.order_by('-id')[0:show_number]
student_list = group.member.order_by('username')
form = AnnounceForm()
user = validate_user(request.user)
user_is_owner = has_group_ownership(user, group)
user_is_coowner = has_group_coownership(user, group)
user_has_auth = user_is_owner or user_is_coowner
running_contest_list = []
ended_contest_list = []
now = timezone.now()
running_contest_list = group.trace_contest.filter(start_time__lte=now, end_time__gte=now)[0:show_number]
ended_contest_list = group.trace_contest.filter(end_time__lte=now)[0:show_number]
student_list = get_current_page(request, student_list)
return render_index(
request, 'group/groupDetail.html', {
'running_contest_list': running_contest_list,
'ended_contest_list': ended_contest_list,
'announce_list': announce_list,
'student_list': student_list,
'group': group,
'user_has_auth': user_has_auth,
'form': form,
'redirect_page' : 'detail',
})
开发者ID:bbiiggppiigg,项目名称:NTHUOJ_web,代码行数:32,代码来源:views.py
示例10: team_list
def team_list(request):
team_profile = {
'id': 1,
'team_name': 'ISeaTeL',
'leader': 'andy',
'member': ['hydai', 'henry'],
'description': 'we are ISeaTel',
'create_time': datetime.datetime.now()
}
team_list = [{}]*200
for i in range(200): # Generate lots of entries for testing paging
team_profile['id'] = i+1
team_list[i] = team_profile.copy()
paginator = Paginator(team_list, 25) # Show 25 teams per page
page = request.GET.get('page')
try:
teams = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
teams = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
teams = paginator.page(paginator.num_pages)
return render_index(
request,
'team/teamList.html',
{'team_list': teams})
开发者ID:bbiiggppiigg,项目名称:NTHUOJ_web,代码行数:30,代码来源:views.py
示例11: download
def download(request):
user = user_info.validate_user(request.user)
if request.method == 'POST':
what = request.POST.get('type')
if what == 'scoreboard':
scoreboard_type = request.POST.get('scoreboard_type')
cid = request.POST.get('contest')
scoreboard_file = get_scoreboard_csv(cid, scoreboard_type)
return scoreboard_file
elif what == 'public_user_password':
cid = request.POST.get('contest')
contest = get_contest_or_404(cid)
if user_info.has_contest_ownership(user, contest) or\
user.has_admin_auth():
logger.info('Contest:User %s download Contest %s - %s public user password!' %
(request.user, contest.id, contest.cname))
return get_public_user_password_csv(contest)
else:
raise PermissionDenied
raise Http404('file not found')
elif request.method == 'GET':
if request.GET.get('cid'):
cid = request.GET.get('cid')
contest = get_contest_or_404(cid)
if user_info.has_contest_ownership(user, contest) or user.has_admin_auth():
return render_index(request,'contest/download.html',{'contest':contest})
else:
raise PermissionDenied
开发者ID:drowsy810301,项目名称:NTHUOJ_web,代码行数:28,代码来源:views.py
示例12: problem
def problem(request):
user = validate_user(request.user)
can_add_problem = user.has_subjudge_auth()
filter_type = request.GET.get('filter')
tag_filter = TagFilter(request.GET)
if tag_filter.is_valid():
tag_name = tag_filter.cleaned_data['tag_name']
if filter_type == 'mine':
problem_list = get_owner_problem_list(user)
mine = True
else:
problem_list = get_problem_list(user)
mine = False
if tag_name:
problem_list = problem_list.filter(tags__tag_name=tag_name)
for p in problem_list:
p.in_contest = check_in_contest(p)
problems = get_current_page(request, problem_list, 15)
for p in problems:
if p.total_submission != 0:
p.pass_rate = float(p.ac_count) / float(p.total_submission) * 100.0
p.not_pass_rate = 100.0 - p.pass_rate
p.pass_rate = "%.2f" % (p.pass_rate)
p.not_pass_rate = "%.2f" % (p.not_pass_rate)
else:
p.no_submission = True
else:
problems = []
mine = False
return render_index(request, 'problem/panel.html',
{'all_problem': problems, 'mine': mine,
'can_add_problem': can_add_problem, 'tag_filter': tag_filter})
开发者ID:bbiiggppiigg,项目名称:NTHUOJ_web,代码行数:32,代码来源:views.py
示例13: contest
def contest(request, cid):
user = user_info.validate_user(request.user)
try:
contest = Contest.objects.get(id = cid)
except Contest.DoesNotExist:
logger.warning('Contest: Can not find contest %s!' % cid)
raise Http404('Contest does not exist')
now = datetime.now()
#if contest has not started and user is not the owner
if ((contest.start_time < now) or\
user_info.has_contest_ownership(user,contest) or\
user.has_admin_auth()):
for problem in contest.problem.all():
problem.testcase = get_testcase(problem)
scoreboard = get_scoreboard(contest)
status = contest_status(request, contest)
clarifications = get_clarifications(user,contest)
initial_form = {'contest':contest,'asker':user}
form = ClarificationForm(initial=initial_form)
initial_reply_form = {'contest':contest,'replier':user}
reply_form = ReplyForm(initial = initial_reply_form)
return render_index(request, 'contest/contest.html',
{'contest':contest, 'clarifications':clarifications,
'form':form, 'reply_form':reply_form,
'scoreboard':scoreboard, 'status': status})
else:
raise PermissionDenied
开发者ID:drowsy810301,项目名称:NTHUOJ_web,代码行数:31,代码来源:views.py
示例14: download
def download(request):
user = user_info.validate_user(request.user)
if request.method == "POST":
what = request.POST.get("type")
if what == "scoreboard":
scoreboard_type = request.POST.get("scoreboard_type")
cid = request.POST.get("contest")
scoreboard_file = get_scoreboard_csv(cid, scoreboard_type)
return scoreboard_file
elif what == "public_user_password":
cid = request.POST.get("contest")
contest = get_contest_or_404(cid)
if user_info.has_contest_ownership(user, contest) or user.has_admin_auth():
logger.info(
"Contest:User %s download Contest %s - %s public user password!"
% (request.user, contest.id, contest.cname)
)
return get_public_user_password_csv(contest)
else:
raise PermissionDenied
raise Http404("file not found")
elif request.method == "GET":
if request.GET.get("cid"):
cid = request.GET.get("cid")
contest = get_contest_or_404(cid)
if user_info.has_contest_ownership(user, contest) or user.has_admin_auth():
return render_index(request, "contest/download.html", {"contest": contest})
else:
raise PermissionDenied
开发者ID:jpdyuki,项目名称:NTHUOJ_web,代码行数:29,代码来源:views.py
示例15: register_page
def register_page(request, cid):
contest = get_contest_or_404(cid)
groups = get_owned_group(request.user)
public_user = len(get_public_contestant(contest))
return render_index(request,
'contest/register.html',
{'contest':contest, 'groups':groups,'max_public_user':settings.MAX_PUBLIC_USER,
'public_user':public_user})
开发者ID:drowsy810301,项目名称:NTHUOJ_web,代码行数:8,代码来源:views.py
示例16: new
def new(request):
if request.user.has_judge_auth():
if request.method == 'GET':
form = GroupForm(
user=request.user, initial={'owner': request.user})
return render_index(request, 'group/editGroup.html', {'form': form})
if request.method == 'POST':
form = GroupForm(request.POST, initial={'owner': request.user})
if form.is_valid():
new_group = form.save()
logger.info('Group: Create a new group %s!' % new_group.id)
return HttpResponseRedirect(reverse('group:list'))
else:
return render_index(
request,
'group/editGroup.html', {'form': form})
else:
raise PermissionDenied
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:18,代码来源:views.py
示例17: user_block_wrong_tries
def user_block_wrong_tries(request):
"""Block login for over 3 wrong tries."""
attempts = AccessAttempt.objects.filter(ip_address=get_ip(request))
for attempt in attempts:
if attempt.failures_since_start >= FAILURE_LIMIT:
unblock_time = attempt.attempt_time + COOLOFF_TIME
return render_index(request, 'users/blockWrongTries.html', {'unblock_time': unblock_time})
# No block attempt
return redirect(reverse('index:index'))
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:9,代码来源:views.py
示例18: list
def list(request):
all_group = Group.objects.order_by('id')
all_group = get_current_page(request, all_group)
return render_index(
request,'group/groupList.html', {
'all_group_list': all_group,
'include_flag': 'all_group',
})
开发者ID:bbiiggppiigg,项目名称:NTHUOJ_web,代码行数:9,代码来源:views.py
示例19: register_page
def register_page(request, cid):
contest = get_contest_or_404(cid)
groups = get_owned_group(request.user)
public_user = len(get_public_contestant(contest))
return render_index(
request,
"contest/register.html",
{"contest": contest, "groups": groups, "max_public_user": settings.MAX_PUBLIC_USER, "public_user": public_user},
)
开发者ID:jpdyuki,项目名称:NTHUOJ_web,代码行数:9,代码来源:views.py
示例20: user_notification
def user_notification(request, current_tab='none'):
unread_notifications = Notification.objects. \
filter(receiver=request.user, read=False).order_by('-id')
all_notifications = Notification.objects. \
filter(receiver=request.user).order_by('-id')
return render_index(request, 'users/notification.html',
{'all_notifications': all_notifications,
'unread_notifications': unread_notifications, 'current_tab': current_tab})
开发者ID:chengscott,项目名称:NTHUOJ_web,代码行数:10,代码来源:views.py
注:本文中的utils.render_helper.render_index函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论