Mercurial > agora-palash
view views.py @ 151:c7be7def8b57
Bundles! (basic functionality)
Changes made in this commit:
* Added new dependencies (see pip-requirements)
* Added new dependency and setup information to README
* Deleted the included mptt app (in apps/mptt) in favour of just adding
the dependency to pip-requirements (makes it easier to update, etc)
* Changed the import convention to use
`from apps.bundle.models import Bundle`
rather than
`from agora.apps.bundle.models import Bundle`
because Celery was having problems with the latter style. Everything
should still work.
* Moved the syntax-highlighting and related code for snippets into
separate HTML files so that they can be used by the bundle app
And, of course, the ability to upload bundles.
But wait! There's more! Changes still to come, for only $19.95 a month:
* Bundle versioning
* Automatic license integration (i.e. adding headers to files)
* The ability to download bundles (zip, tar, etc)
* Rating bundles
* And much, much more!
Batteries not included.
author | dellsystem <ilostwaldo@gmail.com> |
---|---|
date | Mon, 15 Oct 2012 00:52:00 -0400 |
parents | b8e0bdc37e32 |
children | a5547f079190 |
line wrap: on
line source
from django.contrib.auth import login, authenticate from django.contrib.auth.forms import AuthenticationForm from django.shortcuts import render, redirect from django.core.urlresolvers import reverse from registration.forms import RegistrationForm from agora.apps.snippet.models import Snippet from agora.apps.bundle.models import Bundle def code(request): context = { 'snippets': Snippet.objects.public()[:5], 'bundles': Bundle.objects.all()[:5], 'forge': None, # temp } return render(request, 'code.djhtml', context) def login_register(request): form = None next_url = None if request.method == 'POST': action = request.POST.get('action') next_url = request.GET.get('next') or reverse('login') if action == 'login': username = request.POST.get('username', '') password = request.POST.get('password1', '') if username and password: user = authenticate(username=username, password=password) login(request, user) return redirect(next_url) else: form = { 'password1': { 'errors': 'Please enter a username and password.', }, } elif action == 'register': form = RegistrationForm(request.POST) if form.is_valid(): user = form.save() login(request, user) return redirect(next_url) else: # The action is not set. Malicious submission? pass context = { 'next_url': next_url, 'form': form, } return render(request, 'login.djhtml', context)