mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 13:32:15 +00:00
Added viewing user profiles
This commit is contained in:
37
RIGS/templates/RIGS/profile_detail.html
Normal file
37
RIGS/templates/RIGS/profile_detail.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block title %}RIGS Profile {{object.pk}}{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="col-sm-10 col-sm-offset-1">
|
||||
<div class="col-sm-6">
|
||||
<h3>{{object.name}}</h3>
|
||||
<dl class="dl-horizontal">
|
||||
<dt>First Name</dt>
|
||||
<dd>{{object.first_name}}</dd>
|
||||
|
||||
<dt>Last Name</dt>
|
||||
<dd>{{object.last_name}}</dd>
|
||||
|
||||
<dt>Email</dt>
|
||||
<dd>{{object.email}}</dd>
|
||||
|
||||
<dt>Last Login</dt>
|
||||
<dd>{{object.last_login}}</dd>
|
||||
|
||||
<dt>Date Joined</dt>
|
||||
<dd>{{object.date_joined}}</dd>
|
||||
|
||||
<dt>Initials</dt>
|
||||
<dd>{{object.initials}}</dd>
|
||||
|
||||
<dt>Phone</dt>
|
||||
<dd>{{object.phone}}</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="col-sm-3 col-sm-offset-3">
|
||||
<div class="center-block">
|
||||
<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -106,6 +106,13 @@ urlpatterns = patterns('',
|
||||
permission_required_with_403('RIGS.add_payment')(finance.PaymentDelete.as_view()),
|
||||
name='payment_delete'),
|
||||
|
||||
# User editing
|
||||
url(r'^user/$', login_required(views.ProfileDetail.as_view()), name='profile_detail'),
|
||||
url(r'^user/(?P<pk>\d+)/$',
|
||||
permission_required_with_403('RIGS.view_profile')(views.ProfileDetail.as_view()),
|
||||
name='profile_detail'),
|
||||
# url(r'^user/edit/')
|
||||
|
||||
# API
|
||||
url(r'^api/(?P<model>\w+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"),
|
||||
url(r'^api/(?P<model>\w+)/(?P<pk>\d+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"),
|
||||
|
||||
@@ -249,4 +249,16 @@ class SecureAPIRequest(generic.View):
|
||||
json = simplejson.dumps(results[:20])
|
||||
return HttpResponse(json, content_type="application/json") # Always json
|
||||
|
||||
return HttpResponse(model)
|
||||
return HttpResponse(model)
|
||||
|
||||
class ProfileDetail(generic.DetailView):
|
||||
model = models.Profile
|
||||
|
||||
def get_queryset(self):
|
||||
try:
|
||||
pk = self.kwargs['pk']
|
||||
except KeyError:
|
||||
pk = self.request.user.id
|
||||
self.kwargs['pk'] = pk
|
||||
|
||||
return self.model.objects.filter(pk=pk)
|
||||
Reference in New Issue
Block a user