~widelands-dev/widelands-website/trunk

« back to all changes in this revision

Viewing changes to wlprofile/views.py

  • Committer: franku
  • Author(s): GunChleoc
  • Date: 2016-12-13 18:30:38 UTC
  • mfrom: (438.1.6 pyformat_util)
  • Revision ID: somal@arcor.de-20161213183038-5cgmvfh2fkgmoc1s
adding a script to run pyformat over the code base

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
import settings
13
13
 
14
14
# Settings
 
15
 
 
16
 
15
17
@login_required
16
 
def view(request, user = None):
17
 
    """
18
 
    View the profile. Note that login is required here
19
 
    to make sure that not all spam post can harvest here
 
18
def view(request, user=None):
 
19
    """View the profile.
 
20
 
 
21
    Note that login is required here to make sure that not all spam post
 
22
    can harvest here
 
23
 
20
24
    """
21
25
    if user is None:
22
26
        profile = request.user.wlprofile
23
27
    else:
24
 
        profile = User.objects.get( username = user ).wlprofile
 
28
        profile = User.objects.get(username=user).wlprofile
25
29
 
26
30
    template_params = {
27
 
        "profile": profile,
 
31
        'profile': profile,
28
32
    }
29
33
 
30
 
    return render_to_response("wlprofile/view_profile.html",
 
34
    return render_to_response('wlprofile/view_profile.html',
31
35
                              template_params,
32
36
                              context_instance=RequestContext(request))
33
37
 
 
38
 
34
39
@login_required
35
40
def edit(request):
36
41
    instance = request.user.wlprofile
37
42
 
38
43
    if request.method == 'POST':
39
44
        form = EditProfileForm(request.POST,
40
 
                    instance=instance, files = request.FILES)
 
45
                               instance=instance, files=request.FILES)
41
46
        if form.is_valid():
42
47
            form.save()
43
48
 
46
51
        form = EditProfileForm(instance=instance)
47
52
 
48
53
    template_params = {
49
 
        "profile": instance,
50
 
        "profile_form": form,
 
54
        'profile': instance,
 
55
        'profile_form': form,
51
56
    }
52
 
    return render_to_response("wlprofile/edit_profile.html",
 
57
    return render_to_response('wlprofile/edit_profile.html',
53
58
                              template_params,
54
59
                              context_instance=RequestContext(request))
55
 
 
56