def edit_talk(request, talk_id): talk = get_object_or_404(Talk, id=talk_id) if not talk.speaker.user == request.user.profile: messages.add_message( request, messages.WARNING, message=_('You can not make changes to this talk.')) return redirect('show-talk', talk_id) if request.method == 'GET': talk_form = UserTalkForm(instance=talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set context = { 'talk': talk, 'talk_form': talk_form, } return render(request, 'get_together/speakers/edit_talk.html', context) elif request.method == 'POST': talk_form = UserTalkForm(request.POST, instance=talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set if talk_form.is_valid(): talk = talk_form.save() return redirect('show-talk', talk.id) else: context = { 'talk': talk, 'talk_form': talk_form, } return render(request, 'get_together/speakers/edit_talk.html', context) return redirect('home')
def add_talk(request): new_talk = Talk() if request.method == 'GET': talk_form = UserTalkForm(instance=new_talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set context = { 'talk': new_talk, 'talk_form': talk_form, } if 'event' in request.GET and request.GET['event']: context['event'] = get_object_or_404(Event, id=request.GET['event']) return render(request, 'get_together/speakers/create_talk.html', context) elif request.method == 'POST': talk_form = UserTalkForm(request.POST, instance=new_talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set if talk_form.is_valid(): new_talk = talk_form.save() if 'event' in request.POST and request.POST['event']: event = Event.objects.get(id=request.POST['event']) Presentation.objects.create(event=event, talk=new_talk, status=Presentation.PROPOSED, created_by=request.user.profile) return redirect(event.get_absolute_url()) return redirect('show-talk', new_talk.id) else: context = { 'talk': new_talk, 'talk_form': talk_form, } return render(request, 'get_together/speakers/create_talk.html', context) return redirect('home')
def edit_talk(request, talk_id): talk = get_object_or_404(Talk, id=talk_id) if not talk.speaker.user == request.user.profile: messages.add_message( request, messages.WARNING, message=_("You can not make changes to this talk."), ) return redirect("show-talk", talk_id) if request.method == "GET": talk_form = UserTalkForm(instance=talk) talk_form.fields["speaker"].queryset = request.user.profile.speaker_set context = {"talk": talk, "talk_form": talk_form} return render(request, "get_together/speakers/edit_talk.html", context) elif request.method == "POST": talk_form = UserTalkForm(request.POST, instance=talk) talk_form.fields["speaker"].queryset = request.user.profile.speaker_set if talk_form.is_valid(): talk = talk_form.save() return redirect("show-talk", talk.id) else: context = {"talk": talk, "talk_form": talk_form} return render(request, "get_together/speakers/edit_talk.html", context) return redirect("home")
def add_talk(request): if Speaker.objects.filter(user=request.user.profile).count() < 1: messages.add_message( request, messages.WARNING, message= _('You must create a new Speaker profile before you can add a talk' )) set_resume(request) return redirect('add-speaker') new_talk = Talk() if request.method == 'GET': talk_form = UserTalkForm(instance=new_talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set context = { 'talk': new_talk, 'talk_form': talk_form, } if 'event' in request.GET and request.GET['event']: context['event'] = get_object_or_404(Event, id=request.GET['event']) return render(request, 'get_together/speakers/create_talk.html', context) elif request.method == 'POST': talk_form = UserTalkForm(request.POST, instance=new_talk) talk_form.fields['speaker'].queryset = request.user.profile.speaker_set if talk_form.is_valid(): new_talk = talk_form.save() if 'event' in request.POST and request.POST['event']: event = Event.objects.get(id=request.POST['event']) Presentation.objects.create(event=event, talk=new_talk, status=Presentation.PROPOSED, created_by=request.user.profile) return redirect(event.get_absolute_url()) return redirect('show-talk', new_talk.id) else: context = { 'talk': new_talk, 'talk_form': talk_form, } return render(request, 'get_together/speakers/create_talk.html', context) return redirect('home')
def add_talk(request): if Speaker.objects.filter(user=request.user.profile).count() < 1: messages.add_message( request, messages.WARNING, message= _("You must create a new Speaker profile before you can add a talk" ), ) set_resume(request) return redirect("add-speaker") new_talk = Talk() if request.method == "GET": talk_form = UserTalkForm(instance=new_talk) talk_form.fields["speaker"].queryset = request.user.profile.speaker_set context = {"talk": new_talk, "talk_form": talk_form} if "event" in request.GET and request.GET["event"]: context["event"] = get_object_or_404(Event, id=request.GET["event"]) return render(request, "get_together/speakers/create_talk.html", context) elif request.method == "POST": talk_form = UserTalkForm(request.POST, instance=new_talk) talk_form.fields["speaker"].queryset = request.user.profile.speaker_set if talk_form.is_valid(): new_talk = talk_form.save() if "event" in request.POST and request.POST["event"]: event = Event.objects.get(id=request.POST["event"]) Presentation.objects.create( event=event, talk=new_talk, status=Presentation.PROPOSED, created_by=request.user.profile, ) return redirect(event.get_absolute_url()) return redirect("show-talk", new_talk.id) else: context = {"talk": new_talk, "talk_form": talk_form} return render(request, "get_together/speakers/create_talk.html", context) return redirect("home")