mirror of
https://github.com/nottinghamtec/PyRIGS.git
synced 2026-01-23 00:12:15 +00:00
Add user editing
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"
|
||||||
|
|||||||
@@ -4,8 +4,19 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-sm-10 col-sm-offset-1">
|
<div class="col-sm-10 col-sm-offset-1">
|
||||||
<div class="col-sm-6">
|
<div class="col-sm-10">
|
||||||
<h3>{{object.name}}</h3>
|
<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">
|
<dl class="dl-horizontal">
|
||||||
<dt>First Name</dt>
|
<dt>First Name</dt>
|
||||||
<dd>{{object.first_name}}</dd>
|
<dd>{{object.first_name}}</dd>
|
||||||
@@ -29,7 +40,7 @@
|
|||||||
<dd>{{object.phone}}</dd>
|
<dd>{{object.phone}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-3 col-sm-offset-3">
|
<div class="col-sm-3 col-sm-offset-2">
|
||||||
<div class="center-block">
|
<div class="center-block">
|
||||||
<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
|
<img src="{{object.profile_picture}}" class="img-responsive img-rounded" />
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -111,7 +111,8 @@ urlpatterns = patterns('',
|
|||||||
url(r'^user/(?P<pk>\d+)/$',
|
url(r'^user/(?P<pk>\d+)/$',
|
||||||
permission_required_with_403('RIGS.view_profile')(views.ProfileDetail.as_view()),
|
permission_required_with_403('RIGS.view_profile')(views.ProfileDetail.as_view()),
|
||||||
name='profile_detail'),
|
name='profile_detail'),
|
||||||
# url(r'^user/edit/')
|
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"),
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -262,3 +262,17 @@ class ProfileDetail(generic.DetailView):
|
|||||||
self.kwargs['pk'] = pk
|
self.kwargs['pk'] = pk
|
||||||
|
|
||||||
return self.model.objects.filter(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
|
||||||
Reference in New Issue
Block a user