Skip to content

Instantly share code, notes, and snippets.

@tmc
Created November 11, 2012 07:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmc/4054110 to your computer and use it in GitHub Desktop.
Save tmc/4054110 to your computer and use it in GitHub Desktop.
wat django
#views.py
def link_accounts(request):
if request.method == 'POST': # If the form has been submitted...
#De-listify the stupid freakin' post request11!!11
form = LinkForm(initial=init) # A form bound to the POST data
print "HEREEEEEE"
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
token = request.GET.get('token')
events, client = cal_events.getAllEvents(token)
calendars = cal_events.getAllCalendars(client)
calendar_choices = tuple((val, choice) for val, choice in enumerate(calendars))
profiles = request.user.get_profile().profiles
profiles = eval(profiles)
profiles.pop("id")
profile_choices = tuple(((val, choice.capitalize()) for val, choice in enumerate(profiles.keys())))
form = LinkForm(initial= {'calendar_choices': calendar_choices,
'share_choices': profile_choices,
'format_text': 'Hello World'})
return render(request, 'link_form.html', {
'form': form,
})
#forms.py
def link_accounts(request):
if request.method == 'POST': # If the form has been submitted...
#De-listify the stupid freakin' post request11!!11
form = LinkForm(initial=init) # A form bound to the POST data
print "HEREEEEEE"
if form.is_valid(): # All validation rules pass
# Process the data in form.cleaned_data
# ...
return HttpResponseRedirect('/thanks/') # Redirect after POST
else:
token = request.GET.get('token')
events, client = cal_events.getAllEvents(token)
calendars = cal_events.getAllCalendars(client)
calendar_choices = tuple((val, choice) for val, choice in enumerate(calendars))
profiles = request.user.get_profile().profiles
profiles = eval(profiles)
profiles.pop("id")
profile_choices = tuple(((val, choice.capitalize()) for val, choice in enumerate(profiles.keys())))
form = LinkForm(initial= {'calendar_choices': calendar_choices,
'share_choices': profile_choices,
'format_text': 'Hello World'})
return render(request, 'link_form.html', {
'form': form,
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment