Mercurial > public > sg101
comparison gpp/bio/views.py @ 138:7ea842744a57
Ticket #15, add a way to report user profiles.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Fri, 27 Nov 2009 21:55:32 +0000 |
parents | 903ae6168071 |
children | 152d77265da6 |
comparison
equal
deleted
inserted
replaced
137:c7d75cdfea21 | 138:7ea842744a57 |
---|---|
4 | 4 |
5 from django.shortcuts import render_to_response | 5 from django.shortcuts import render_to_response |
6 from django.shortcuts import get_object_or_404 | 6 from django.shortcuts import get_object_or_404 |
7 from django.template import RequestContext | 7 from django.template import RequestContext |
8 from django.contrib import auth | 8 from django.contrib import auth |
9 from django.http import HttpResponse | |
10 from django.http import HttpResponseBadRequest | |
9 from django.http import HttpResponseRedirect | 11 from django.http import HttpResponseRedirect |
10 from django.core.paginator import InvalidPage | 12 from django.core.paginator import InvalidPage |
11 from django.core.urlresolvers import reverse | 13 from django.core.urlresolvers import reverse |
12 from django.contrib.auth.decorators import login_required | 14 from django.contrib.auth.decorators import login_required |
15 from django.views.decorators.http import require_POST | |
13 | 16 |
14 from elsewhere.models import SocialNetworkForm | 17 from elsewhere.models import SocialNetworkForm |
15 from elsewhere.models import InstantMessengerForm | 18 from elsewhere.models import InstantMessengerForm |
16 from elsewhere.models import WebsiteForm | 19 from elsewhere.models import WebsiteForm |
17 | 20 |
18 from bio.models import UserProfile | 21 from bio.models import UserProfile |
22 from bio.models import UserProfileFlag | |
19 from bio.forms import UploadAvatarForm | 23 from bio.forms import UploadAvatarForm |
20 from bio.forms import EditUserForm | 24 from bio.forms import EditUserForm |
21 from bio.forms import EditUserProfileForm | 25 from bio.forms import EditUserProfileForm |
22 from core.paginator import DiggPaginator | 26 from core.paginator import DiggPaginator |
27 from core.functions import email_admins | |
23 | 28 |
24 ####################################################################### | 29 ####################################################################### |
25 | 30 |
26 @login_required | 31 @login_required |
27 def member_list(request, type='user', page=1): | 32 def member_list(request, type='user', page=1): |
137 | 142 |
138 return render_to_response('bio/avatar.html', { | 143 return render_to_response('bio/avatar.html', { |
139 'form': form, | 144 'form': form, |
140 }, | 145 }, |
141 context_instance = RequestContext(request)) | 146 context_instance = RequestContext(request)) |
147 | |
148 ####################################################################### | |
149 | |
150 @require_POST | |
151 def flag_profile(request, profile_id): | |
152 """ | |
153 This function handles the flagging of profiles by users. This function should | |
154 be the target of an AJAX post. | |
155 """ | |
156 if not request.user.is_authenticated(): | |
157 return HttpResponse('Please login or register to flag a profile.') | |
158 | |
159 try: | |
160 profile = UserProfile.objects.get(pk=profile_id) | |
161 except UserProfile.DoesNotExist: | |
162 return HttpResponseBadRequest("That profile doesn't exist.") | |
163 | |
164 flag = UserProfileFlag(user=request.user, profile=profile) | |
165 flag.save() | |
166 email_admins('A Profile Has Been Flagged', """Hello, | |
167 | |
168 A user has flagged a profile for review. | |
169 """) | |
170 return HttpResponse('The profile was flagged. A moderator will review the' \ | |
171 ' profile shortly. Thanks for helping to improve the content on this ' \ | |
172 'site.') | |
142 | 173 |
143 ####################################################################### | 174 ####################################################################### |
144 | 175 |
145 @login_required | 176 @login_required |
146 def edit_elsewhere(request): | 177 def edit_elsewhere(request): |