mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-17 05:22:16 +00:00
Merged in users (pull request #1)
Ability to view a users details and edit them
This commit is contained in:
@@ -23,7 +23,7 @@ DEBUG = True
|
|||||||
|
|
||||||
TEMPLATE_DEBUG = True
|
TEMPLATE_DEBUG = True
|
||||||
|
|
||||||
ALLOWED_HOSTS = []
|
ALLOWED_HOSTS = ['*']
|
||||||
|
|
||||||
INTERNAL_IPS = ['127.0.0.1', '10.20.30.20']
|
INTERNAL_IPS = ['127.0.0.1', '10.20.30.20']
|
||||||
|
|
||||||
@@ -143,4 +143,6 @@ TEMPLATE_DIRS = (
|
|||||||
os.path.join(BASE_DIR, 'templates'),
|
os.path.join(BASE_DIR, 'templates'),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
USE_GRAVATAR=True
|
||||||
|
|
||||||
TERMS_OF_HIRE_URL = "http://dev.nottinghamtec.co.uk/wp-content/uploads/2014/11/terms.pdf"
|
TERMS_OF_HIRE_URL = "http://dev.nottinghamtec.co.uk/wp-content/uploads/2014/11/terms.pdf"
|
||||||
|
|||||||
48
RIGS/templates/RIGS/profile_detail.html
Normal file
48
RIGS/templates/RIGS/profile_detail.html
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
{% 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-10">
|
||||||
|
<h3>{{object.name}}</h3>
|
||||||
|
</div>
|
||||||
|
{% if object.pk == user.pk %}
|
||||||
|
<div class="col-sm-2">
|
||||||
|
<div class="pull-right">
|
||||||
|
<a href="{% url 'profile_update_self' %}" class="btn btn-primary">
|
||||||
|
Edit <span class="glyphicon glyphicon-pencil"></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<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-2">
|
||||||
|
<div class="center-block">
|
||||||
|
<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
71
RIGS/templates/RIGS/profile_form.html
Normal file
71
RIGS/templates/RIGS/profile_form.html
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
{% extends 'base.html' %}
|
||||||
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
{% block title %}Update Profile {{object.name}}{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-10 col-sm-offset-1">
|
||||||
|
{% include 'form_errors.html' %}
|
||||||
|
<h3>Update Profile</h3>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<form action="{{form.action|default:request.path}}" method="post" class="form-horizontal">{% csrf_token %}
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{form.first_name.id_for_label}}" class="col-sm-4 control-label">{{form.first_name.label}}</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.first_name class+="form-control" placeholder=form.first_name.label %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{form.last_name.id_for_label}}" class="col-sm-4 control-label">{{form.last_name.label}}</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.last_name class+="form-control" placeholder=form.last_name.label %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{form.email.id_for_label}}" class="col-sm-4 control-label">{{form.email.label}}</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.email type="email" class+="form-control" placeholder=form.email.label %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{form.initials.id_for_label}}" class="col-sm-4 control-label">{{form.initials.label}}</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.initials class+="form-control" placeholder=form.initials.label %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label for="{{form.phone.id_for_label}}" class="col-sm-4 control-label">{{form.phone.label}}</label>
|
||||||
|
|
||||||
|
<div class="col-sm-8">
|
||||||
|
{% render_field form.phone type="tel" class+="form-control" placeholder=form.phone.label %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<input class="btn btn-primary pull-right" type="submit"/>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-sm-3 col-sm-offset-2">
|
||||||
|
<div class="center-block">
|
||||||
|
<a href="https://gravatar.com/">
|
||||||
|
<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
|
||||||
|
<div class="text-center">
|
||||||
|
Images hosted by Gravatar
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
||||||
@@ -106,6 +106,14 @@ urlpatterns = patterns('',
|
|||||||
permission_required_with_403('RIGS.add_payment')(finance.PaymentDelete.as_view()),
|
permission_required_with_403('RIGS.add_payment')(finance.PaymentDelete.as_view()),
|
||||||
name='payment_delete'),
|
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/$', login_required(views.ProfileUpdateSelf.as_view()),
|
||||||
|
name='profile_update_self'),
|
||||||
|
|
||||||
# API
|
# API
|
||||||
url(r'^api/(?P<model>\w+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"),
|
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"),
|
url(r'^api/(?P<model>\w+)/(?P<pk>\d+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"),
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ from django.core import serializers
|
|||||||
import simplejson
|
import simplejson
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
|
|
||||||
from RIGS import models
|
from RIGS import models, forms
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Displays the current rig count along with a few other bits and pieces
|
Displays the current rig count along with a few other bits and pieces
|
||||||
@@ -257,4 +257,30 @@ class SecureAPIRequest(generic.View):
|
|||||||
json = simplejson.dumps(results[:20])
|
json = simplejson.dumps(results[:20])
|
||||||
return HttpResponse(json, content_type="application/json") # Always json
|
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)
|
||||||
|
|
||||||
|
class ProfileUpdateSelf(generic.UpdateView):
|
||||||
|
model = models.Profile
|
||||||
|
fields = ['first_name', 'last_name', 'email', 'initials', 'phone']
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
pk = self.request.user.id
|
||||||
|
self.kwargs['pk'] = pk
|
||||||
|
|
||||||
|
return self.model.objects.filter(pk=pk)
|
||||||
|
|
||||||
|
def get_success_url(self):
|
||||||
|
url = reverse_lazy('profile_detail')
|
||||||
|
return url
|
||||||
@@ -76,18 +76,22 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu nav media-list pull-right" id="userdropdown">
|
<ul class="dropdown-menu nav media-list pull-right" id="userdropdown">
|
||||||
<li class="media">
|
<li class="media">
|
||||||
<div class="media-left">
|
<a href="{% url 'profile_detail' %}">
|
||||||
<img src="{{ request.user.profile_picture }}" class="media-object"/>
|
<div class="media-left">
|
||||||
</div>
|
<img src="{{ request.user.profile_picture }}" class="media-object"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="media-body">
|
<div class="media-body">
|
||||||
<b>{{ request.user.first_name }} {{ request.user.last_name }}</b>
|
<b>{{ request.user.first_name }} {{ request.user.last_name }}</b>
|
||||||
|
|
||||||
<p class="muted">{{ request.user.email }}</p>
|
<p class="muted">{{ request.user.email }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<a href="{% url 'logout' %}" class="btn btn-primary pull-right">Logout</a>
|
<div class="col-sm-12 text-right">
|
||||||
|
<a href="{% url 'logout' %}" class="btn btn-primary">Logout</a>
|
||||||
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|||||||
Reference in New Issue
Block a user