def edit_challenge_config_message(request, message_id): message_config = get_object_or_404(ChallengeServiceMessageConfiguration, id=message_id) form = ChallengeMessageConfigurationForm(initial=message_config.__dict__) if request.method == 'POST': form = ChallengeMessageConfigurationForm(data=request.POST) if form.is_valid(): message_config.notify_after = form.cleaned_data['notify_after'] message_config.message = form.cleaned_data['message'] message_config.save() return HttpResponseRedirect('/spudderadmin/challenges') template_data = {'form': form} return render(request, 'spudderadmin/pages/challenges/edit_config_form.html', template_data)
def add_challenge_config_message(request): challenge_config = ChallengeServiceConfiguration.GetForSite() form = ChallengeMessageConfigurationForm() if request.method == 'POST': form = ChallengeMessageConfigurationForm(data=request.POST) if form.is_valid(): data = form.cleaned_data message_config = ChallengeServiceMessageConfiguration( configuration=challenge_config, notify_after=data['notify_after'], message=data['message'] ) message_config.save() return HttpResponseRedirect('/spudderadmin/challenges') template_data = {'form': form} return render(request, 'spudderadmin/pages/challenges/edit_config_form.html', template_data)
def add_challenge_config_message(request): challenge_config = ChallengeServiceConfiguration.GetForSite() form = ChallengeMessageConfigurationForm() if request.method == 'POST': form = ChallengeMessageConfigurationForm(data=request.POST) if form.is_valid(): data = form.cleaned_data message_config = ChallengeServiceMessageConfiguration( configuration=challenge_config, notify_after=data['notify_after'], message=data['message']) message_config.save() return HttpResponseRedirect('/spudderadmin/challenges') template_data = {'form': form} return render(request, 'spudderadmin/pages/challenges/edit_config_form.html', template_data)