本文整理汇总了Python中models.WorkshopGame类的典型用法代码示例。如果您正苦于以下问题:Python WorkshopGame类的具体用法?Python WorkshopGame怎么用?Python WorkshopGame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WorkshopGame类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: workshop_mark4review
def workshop_mark4review(request, workshop):
workshop = get_object_or_404(Workshop, pk=workshop)
if workshop.is_started():
WorkshopGame.start_reviewing(workshop)
return redirect('ws_workshops')
示例2: index
def index(request, extra_context=None):
player = request.user.get_profile()
assessment = WorkshopGame.get_for_player_now(player)
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assessment': assessment, 'semigroup': Semigroup.get_by_player(player)})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)
示例3: index
def index(request, extra_context=None):
player = request.user.get_profile()
assesment = Assesment.get_for_player_and_workshop(request.user.get_profile(), WorkshopGame.get_for_now())
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assesment': assesment})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)
示例4: schedule_change
def schedule_change(request, schedule=None):
class SCForm(forms.ModelForm):
class Meta:
model = Schedule
fields = ('name', 'start_date', 'end_date')
if schedule:
schedule = get_object_or_404(Schedule, pk=schedule)
if request.method == 'POST':
form = SCForm(request.POST, instance=schedule)
if form.is_valid():
sc = form.save()
sc.category = WorkshopGame.get_question_category()
sc.save()
return redirect('ws_schedule')
else:
form = SCForm(instance=schedule)
return render_to_response('workshop/cpanel/schedule_change.html',
{'module': 'workshop',
'form': form,
'instance': schedule},
context_instance=RequestContext(request)
)
示例5: index
def index(request, extra_context=None):
player = request.user.get_profile()
workshop = WorkshopGame.get_for_player_now(player)
assessment = workshop.get_or_create_assessment(player) if workshop else None
if not extra_context:
extra_context = {}
extra_context.update({'workshopgame': WorkshopGame, 'workshop': WorkshopGame.get_for_player_now(player),
'assessment': assessment, 'semigroup': Semigroup.get_by_player(player),
'history': player.assessments.all().order_by('-workshop__active_until')})
return render_to_response('workshop/index.html',
extra_context,
context_instance=RequestContext(request)
)
示例6: play
def play(request):
"""
Play current workshop or show expired message.
"""
workshop = WorkshopGame.get_for_now()
player = request.user.get_profile()
error = ''
if not workshop:
return do_error(request, _('No current workshop'))
elif player not in workshop.semigroup.players.all():
return do_error(request, _('You are not in the current semigroup'))
elif not workshop.is_active():
return do_error(request, _('Workshop is not active'))
assesment = Assesment.objects.get_or_create(player=player, workshop=workshop)[0]
if assesment.answered:
return do_error(request, _('You have already answered this workshop'))
if request.method == 'POST':
answers = {}
for q in workshop.questions.all():
answers[q.id] = request.POST.get('answer_%d' % q.id)
assesment.set_answered(answers)
return redirect('workshop_index_view')
return render_to_response('workshop/play.html',
{'assesment': assesment,
'workshop': workshop},
context_instance=RequestContext(request)
)
示例7: play
def play(request):
"""
Play current workshop or show expired message.
"""
player = request.user.get_profile()
workshop = WorkshopGame.get_for_player_now(player=player)
if not workshop:
return do_error(request, _('No workshop for you'))
if not workshop.is_active():
return do_error(request, _('Workshop is not active'))
assessment = workshop.get_or_create_assessment(player=player)
if assessment.answered:
return do_error(request, _('You have already answered this workshop'))
if request.method == 'POST':
answers = {}
for q in assessment.questions.all():
answers[q.id] = request.POST.get('answer_%d' % q.id)
assessment.set_answered(answers)
return redirect('workshop_results', workshop=workshop.id)
seconds_left = assessment.time_left()
return render_to_response(
'workshop/play.html',
{'assessment': assessment,
'workshop': workshop,
'seconds_left': seconds_left},
context_instance=RequestContext(request)
)
示例8: kick_off
def kick_off(request, player):
player = get_object_or_404(Player, pk=player)
sgs = player.playergroup_set.filter(owner=WorkshopGame.get_instance())
for s in sgs:
s.players.remove(player)
return redirect('workshop_home')
示例9: schedule
def schedule(request):
schedules = Schedule.objects.all().order_by('start_date', 'name')
return render_to_response('workshop/cpanel/schedule.html',
{'module': 'workshop',
'schedules': schedules,
'category': WorkshopGame.get_question_category(),
'page': 'schedule'},
context_instance=RequestContext(request)
)
示例10: add_group
def add_group(request):
if request.method == 'POST':
form = AGForm(request.POST)
if form.is_valid():
sg = form.save()
sg.owner = WorkshopGame.get_instance()
sg.save()
return redirect('ws_edit_spot', day=sg.day, hour=sg.hour)
else:
form = AGForm()
return render_to_response('workshop/cpanel/addgroup.html',
{'module': 'workshop',
'form': form,
},
context_instance=RequestContext(request)
)
示例11: post
def post(self, request, *args, **kwargs):
error = ''
form = WAForm(request.POST)
if form.is_valid():
error = WorkshopGame.create_workshop(semigroup=form.cleaned_data['semigroup'],
date=form.cleaned_data['date'],
title=form.cleaned_data['title'],
question_count=form.cleaned_data['question_count']
)
if not error:
return redirect('ws_workshops')
return render_to_response('workshop/cpanel/workshop_add.html',
{'module': 'workshop', 'form': form, 'info': WorkshopGame, 'error': error,
'page': 'workshops'},
context_instance=RequestContext(request)
)
示例12: workshop_add
def workshop_add(request):
error = ''
if request.method == 'POST':
form = WAForm(request.POST)
if form.is_valid():
error = WorkshopGame.create_workshop(semigroup=form.cleaned_data['semigroup'],
date=form.cleaned_data['date'],
question_count=form.cleaned_data['question_count']
)
if not error:
return redirect('ws_workshops')
else:
form = WAForm()
return render_to_response('workshop/cpanel/workshop_add.html',
{'module': 'workshop', 'form': form, 'info': WorkshopGame, 'error': error},
context_instance=RequestContext(request)
)
示例13: edit_group
def edit_group(request, semigroup):
semigroup = get_object_or_404(Semigroup, pk=semigroup)
if request.method == 'POST':
form = AGForm(request.POST, instance=semigroup)
if form.is_valid():
sg = form.save()
sg.owner = WorkshopGame.get_instance()
sg.save()
return redirect('ws_edit_spot', day=sg.day, hour=sg.hour)
else:
form = AGForm(instance=semigroup)
return render_to_response('workshop/cpanel/editgroup.html',
{'module': 'workshop',
'form': form,
'instance': semigroup,
},
context_instance=RequestContext(request)
)
示例14: edit_spot
def edit_spot(request, day, hour):
day, hour = int(day), int(hour)
sgs = WorkshopGame.get_by_day_and_hour(day, hour)
if not sgs:
return redirect('ws_add_group')
if request.method == 'POST':
semigroup = get_object_or_404(Semigroup, pk=request.GET.get('semigroup'))
try:
player = Player.objects.get(pk=int(request.POST.get('player')))
except (ValueError, Player.DoesNotExist):
pass
else:
semigroup.add_player(player)
return render_to_response(
'workshop/cpanel/editspot.html',
{'module': 'workshop', 'semigroups': sgs},
context_instance=RequestContext(request)
)
示例15: schedule_change
def schedule_change(request, schedule=None):
if schedule:
schedule = get_object_or_404(Schedule, pk=schedule)
if request.method == 'POST':
form = SCForm(request.POST, instance=schedule)
if form.is_valid():
sc = form.save()
sc.category = WorkshopGame.get_question_category()
sc.save()
return redirect('ws_schedule')
else:
form = SCForm(instance=schedule)
return render_to_response('workshop/cpanel/schedule_change.html',
{'module': 'workshop',
'form': form,
'instance': schedule,
'page': 'schedule'},
context_instance=RequestContext(request)
)