def new_event_start(request): team = request.user.profile.personal_team new_event = Event(team=team, created_by=request.user.profile) if request.method == 'GET': form = NewEventForm(instance=new_event) context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/new_event/create_event.html', context) elif request.method == 'POST': form = NewEventForm(request.POST, instance=new_event) if form.is_valid: new_event = form.save() Attendee.objects.create(event=new_event, user=request.user.profile, role=Attendee.HOST, status=Attendee.YES) messages.add_message(request, messages.SUCCESS, message=_('Your event has been scheduled! Next, find a place for your event.')) ga.add_event(request, action='new_event', category='activity', label=new_event.get_full_url()) return redirect('new-event-add-place', new_event.id) else: context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/new_event/create_event.html', context) else: return redirect('home')
def create_event(request, team_id): team = get_object_or_404(Team, id=team_id) if not request.user.profile.can_create_event(team): messages.add_message( request, messages.WARNING, message=_('You can not create events for this team.')) return redirect('show-team', team_id=team.pk) new_event = Event(team=team, created_by=request.user.profile) if request.method == 'GET': if 'common' in request.GET and request.GET['common'] != '': new_event.parent = CommonEvent.objects.get( id=request.GET['common']) form = NewTeamEventForm(instance=new_event) context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/events/create_event.html', context) elif request.method == 'POST': if 'common' in request.POST and request.POST['common'] != '': new_event.parent = CommonEvent.objects.get( id=request.POST['common']) form = NewTeamEventForm(request.POST, instance=new_event) if form.is_valid: new_event = form.save() Attendee.objects.create(event=new_event, user=request.user.profile, role=Attendee.HOST, status=Attendee.YES) if form.cleaned_data.get('recurrences', None): new_series = EventSeries.from_event( new_event, recurrences=form.cleaned_data['recurrences']) new_series.save() new_event.series = new_series new_event.save() messages.add_message( request, messages.SUCCESS, message= _('Your event has been scheduled! Next, find a place for your event.' )) return redirect('add-place', new_event.id) else: context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/events/create_event.html', context) else: return redirect('home')
def create_event(request, team_id): team = Team.objects.get(id=team_id) if not request.user.profile.can_create_event(team): messages.add_message( request, messages.WARNING, message=_('You can not create events for this team.')) return redirect('show-team', team_id=team.pk) new_event = Event(team=team, created_by=request.user.profile) if request.method == 'GET': if 'common' in request.GET and request.GET['common'] != '': new_event.parent = CommonEvent.objects.get( id=request.GET['common']) form = NewTeamEventForm(instance=new_event) context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/events/create_event.html', context) elif request.method == 'POST': if 'common' in request.POST and request.POST['common'] != '': new_event.parent = CommonEvent.objects.get( id=request.POST['common']) form = NewTeamEventForm(request.POST, instance=new_event) if form.is_valid: new_event = form.save() Attendee.objects.create(event=new_event, user=request.user.profile, role=Attendee.HOST, status=Attendee.YES) return redirect('add-place', new_event.id) else: context = { 'event': new_event, 'team': team, 'event_form': form, } return render(request, 'get_together/events/create_event.html', context) else: return redirect('home')
def new_event_start(request): team = request.user.profile.personal_team new_event = Event(team=team, created_by=request.user.profile) if request.method == "GET": form = NewEventForm(instance=new_event) context = {"event": new_event, "team": team, "event_form": form} return render(request, "get_together/new_event/create_event.html", context) elif request.method == "POST": form = NewEventForm(request.POST, instance=new_event) if form.is_valid: new_event = form.save() Attendee.objects.create( event=new_event, user=request.user.profile, role=Attendee.HOST, status=Attendee.YES, ) messages.add_message( request, messages.SUCCESS, message=_( "Your event has been scheduled! Next, find a place for your event." ), ) ga.add_event( request, action="new_event", category="activity", label=new_event.get_full_url(), ) return redirect("new-event-add-place", new_event.id) else: context = {"event": new_event, "team": team, "event_form": form} return render(request, "get_together/new_event/create_event.html", context) else: return redirect("home")
def create_event(request, team_id): team = get_object_or_404(Team, id=team_id) if not request.user.profile.can_create_event(team): messages.add_message( request, messages.WARNING, message=_("You can not create events for this team."), ) return redirect("show-team-by-slug", team_slug=team.slug) new_event = Event(team=team, created_by=request.user.profile) if request.method == "GET": initial = {} if "common" in request.GET and request.GET["common"] != "": new_event.parent = CommonEvent.objects.get( id=request.GET["common"]) initial["name"] = new_event.parent.name initial["summary"] = new_event.parent.summary initial["start_time"] = new_event.parent.start_time initial["end_time"] = new_event.parent.end_time form = NewTeamEventForm(instance=new_event, initial=initial) context = {"event": new_event, "team": team, "event_form": form} return render(request, "get_together/events/create_event.html", context) elif request.method == "POST": if "common" in request.POST and request.POST["common"] != "": new_event.parent = CommonEvent.objects.get( id=request.POST["common"]) form = NewTeamEventForm(request.POST, instance=new_event) if form.is_valid: new_event = form.save() Attendee.objects.create( event=new_event, user=request.user.profile, role=Attendee.HOST, status=Attendee.YES, ) if form.cleaned_data.get("recurrences", None): new_series = EventSeries.from_event( new_event, recurrences=form.cleaned_data["recurrences"]) new_series.save() new_event.series = new_series new_event.save() messages.add_message( request, messages.SUCCESS, message= _("Your event has been scheduled! Next, find a place for your event." ), ) ga.add_event( request, action="new_event", category="activity", label=new_event.get_full_url(), ) return redirect("add-place", new_event.id) else: context = {"event": new_event, "team": team, "event_form": form} return render(request, "get_together/events/create_event.html", context) else: return redirect("home")