freehg /

from freehg.repos.models import Repo
from django.contrib.auth.models import User
from django.shortcuts import get_object_or_404, render_to_response
from django.template import RequestContext
from django.contrib.auth.decorators import login_required
from django.http import HttpResponseRedirect
from django import newforms as forms

def profile(request):
    user = request.user
    if request.method == 'POST':
        form = ChangeProfileForm(request.POST)
        if form.is_valid():
            user.message_set.create(message="Profile updated.")
            return HttpResponseRedirect("/accounts/profile/")
        form = ChangeProfileForm(dict(
    disk_usage = Repo.objects.get_user_disk_usage(user)
    return render_to_response('profile.html',
            dict(form=form, disk_usage=disk_usage),

class ChangeProfileForm(forms.Form):
    first_name = forms.CharField(max_length=30, required=False)
    last_name = forms.CharField(max_length=30, required=False)
    email = forms.EmailField(required=False)

    def update_user(self, user):
        user.first_name = self.cleaned_data['first_name']
        user.last_name = self.cleaned_data['last_name'] = self.cleaned_data['email']
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.