2013-01-12 09:45:20 -08:00
|
|
|
from django.contrib.auth.decorators import login_required
|
|
|
|
from django.http import HttpResponseRedirect
|
|
|
|
from annoying.decorators import render_to
|
2013-01-13 09:51:25 -08:00
|
|
|
from accounts.forms import AccountForm
|
|
|
|
from django.contrib import messages
|
2013-01-12 09:45:20 -08:00
|
|
|
from snipts.models import Snipt
|
|
|
|
|
|
|
|
@login_required
|
|
|
|
@render_to('account.html')
|
|
|
|
def account(request):
|
2013-01-13 09:51:25 -08:00
|
|
|
|
|
|
|
if request.POST:
|
|
|
|
form = AccountForm(request.POST, instance=request.user.profile)
|
|
|
|
|
|
|
|
if form.is_valid():
|
|
|
|
form.save()
|
|
|
|
messages.add_message(request, 25, 'Account settings saved.')
|
|
|
|
return HttpResponseRedirect('/account/')
|
|
|
|
|
|
|
|
else:
|
2013-01-15 21:09:54 -08:00
|
|
|
profile = request.user.profile
|
|
|
|
|
|
|
|
form = AccountForm(initial={
|
|
|
|
'blog_title': profile.blog_title,
|
|
|
|
'blog_theme': profile.blog_theme,
|
2013-02-02 20:01:34 -08:00
|
|
|
'blog_domain': profile.blog_domain,
|
|
|
|
|
2013-02-04 11:40:45 -08:00
|
|
|
'default_editor': profile.default_editor,
|
2013-02-05 12:24:51 -08:00
|
|
|
'editor_theme': profile.editor_theme,
|
2013-02-04 11:40:45 -08:00
|
|
|
|
2013-02-02 20:01:34 -08:00
|
|
|
'gittip_username': profile.gittip_username,
|
|
|
|
'disqus_shortname': profile.disqus_shortname,
|
2013-02-05 06:59:43 -08:00
|
|
|
'google_analytics_tracking_id': profile.google_analytics_tracking_id,
|
2013-02-07 07:58:26 -08:00
|
|
|
'gauges_site_id': profile.gauges_site_id,
|
2013-02-08 21:06:22 -08:00
|
|
|
|
|
|
|
'google_ad_client': profile.google_ad_client,
|
|
|
|
'google_ad_slot': profile.google_ad_slot,
|
|
|
|
'google_ad_width': profile.google_ad_width,
|
|
|
|
'google_ad_height': profile.google_ad_height,
|
2013-01-15 21:09:54 -08:00
|
|
|
})
|
2013-01-13 09:51:25 -08:00
|
|
|
|
|
|
|
return {
|
|
|
|
'form': form
|
|
|
|
}
|
2013-01-12 09:45:20 -08:00
|
|
|
|
|
|
|
@login_required
|
|
|
|
@render_to('stats.html')
|
|
|
|
def stats(request):
|
|
|
|
|
|
|
|
if not request.user.profile.is_pro:
|
|
|
|
return HttpResponseRedirect('/pro/')
|
|
|
|
|
|
|
|
snipts = Snipt.objects.filter(user=request.user).order_by('-views')
|
|
|
|
|
|
|
|
return {
|
|
|
|
'snipts': snipts
|
|
|
|
}
|