def create_team(request, *args, **kwargs): if request.method == 'GET': form = NewTeamForm() context = { 'team_form': form, } return render(request, 'get_together/teams/create_team.html', context) elif request.method == 'POST': form = NewTeamForm(request.POST) if form.is_valid: new_team = form.save() new_team.owner_profile = request.user.profile new_team.save() Member.objects.create(team=new_team, user=request.user.profile, role=Member.ADMIN) return redirect('show-team', team_id=new_team.pk) else: context = { 'team_form': form, } return render(request, 'get_together/teams/create_team.html', context) else: return redirect('home')
def start_new_team(request, *args, **kwargs): if request.method == 'GET': form = NewTeamForm() g = location.get_geoip(request) if g.latlng is not None and g.latlng[0] is not None and g.latlng[ 1] is not None: city = location.get_nearest_city(g.latlng) if city: form.initial = {'city': city, 'tz': city.tz} context = { 'team_form': form, } return render(request, 'get_together/new_team/start_new_team.html', context) elif request.method == 'POST': form = NewTeamForm(request.POST) if form.is_valid(): new_team = form.save() new_team.owner_profile = request.user.profile new_team.save() Member.objects.create(team=new_team, user=request.user.profile, role=Member.ADMIN) return redirect('define-team', team_id=new_team.pk) else: context = { 'team_form': form, } return render(request, 'get_together/new_team/start_new_team.html', context) else: return redirect('home')
def start_new_team(request): new_team = Team(owner_profile=request.user.profile) new_team.owner_profile = request.user.profile if request.method == 'GET': if 'organization' in request.GET and request.GET['organization'] != '': org = Organization.objects.get(id=request.GET['organization']) if request.user.profile.can_edit_org(org): new_team.organization = org form = NewTeamForm(instance=new_team) g = location.get_geoip(request) if g.latlng is not None and g.latlng[0] is not None and g.latlng[1] is not None: city = location.get_nearest_city(g.latlng) if city: form.initial={'city': city, 'tz': city.tz} context = { 'team': new_team, 'team_form': form, } if 'event' in request.GET and request.GET['event'] != '': context['event'] = request.GET['event'] return render(request, 'get_together/new_team/start_new_team.html', context) elif request.method == 'POST': if 'organization' in request.POST and request.POST['organization'] != '': org = Organization.objects.get(id=request.POST['organization']) if request.user.profile.can_edit_org(org): new_team.organization = org form = NewTeamForm(request.POST, request.FILES, instance=new_team) if form.is_valid(): new_team = form.save() new_team.save() if 'event' in request.POST and request.POST['event'] != '': try: event = Event.objects.get(id=request.POST['event']) event.team = new_team event.save() except: pass Member.objects.create(team=new_team, user=request.user.profile, role=Member.ADMIN) ga.add_event(request, action='new_team', category='growth', label=new_team.name) return redirect('define-team', team_id=new_team.pk) else: context = { 'team': new_team, 'team_form': form, } if 'event' in request.POST and request.POST['event'] != '': context['event'] = request.POST['event'] return render(request, 'get_together/new_team/start_new_team.html', context) else: return redirect('home')
def start_new_team(request): new_team = Team(owner_profile=request.user.profile) new_team.owner_profile = request.user.profile if request.method == "GET": if "organization" in request.GET and request.GET["organization"] != "": org = Organization.objects.get(id=request.GET["organization"]) if request.user.profile.can_edit_org(org): new_team.organization = org form = NewTeamForm(instance=new_team) g = location.get_geoip(request) if g.latlng is not None and g.latlng[0] is not None and g.latlng[1] is not None: city = location.get_nearest_city(g.latlng) if city: form.initial = {"city": city, "tz": city.tz} context = {"team": new_team, "team_form": form} if "event" in request.GET and request.GET["event"] != "": context["event"] = request.GET["event"] return render(request, "get_together/new_team/start_new_team.html", context) elif request.method == "POST": if "organization" in request.POST and request.POST["organization"] != "": org = Organization.objects.get(id=request.POST["organization"]) if request.user.profile.can_edit_org(org): new_team.organization = org form = NewTeamForm(request.POST, request.FILES, instance=new_team) if form.is_valid(): new_team = form.save() new_team.save() if "event" in request.POST and request.POST["event"] != "": try: event = Event.objects.get(id=request.POST["event"]) event.team = new_team event.save() except: pass Member.objects.create( team=new_team, user=request.user.profile, role=Member.ADMIN ) ga.add_event( request, action="new_team", category="growth", label=new_team.name ) return redirect("define-team", team_id=new_team.pk) else: context = {"team": new_team, "team_form": form} if "event" in request.POST and request.POST["event"] != "": context["event"] = request.POST["event"] return render(request, "get_together/new_team/start_new_team.html", context) else: return redirect("home")
def create_team(request, *args, **kwargs): if request.method == "GET": form = NewTeamForm() context = {"team_form": form} return render(request, "get_together/teams/create_team.html", context) elif request.method == "POST": form = NewTeamForm(request.POST, request.FILES) if form.is_valid(): new_team = form.save() new_team.owner_profile = request.user.profile new_team.save() Member.objects.create(team=new_team, user=request.user.profile, role=Member.ADMIN) return redirect("show-team-by-slug", team_slug=new_team.slug) else: context = {"team_form": form} return render(request, "get_together/teams/create_team.html", context) else: return redirect("home")