diff --git a/PyRIGS/settings.py b/PyRIGS/settings.py index 1e8486cb..d1aa118a 100644 --- a/PyRIGS/settings.py +++ b/PyRIGS/settings.py @@ -23,7 +23,7 @@ DEBUG = True TEMPLATE_DEBUG = True -ALLOWED_HOSTS = [] +ALLOWED_HOSTS = ['*'] INTERNAL_IPS = ['127.0.0.1', '10.20.30.20'] @@ -143,4 +143,6 @@ TEMPLATE_DIRS = ( 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" diff --git a/RIGS/templates/RIGS/profile_detail.html b/RIGS/templates/RIGS/profile_detail.html new file mode 100644 index 00000000..a9d9bbaf --- /dev/null +++ b/RIGS/templates/RIGS/profile_detail.html @@ -0,0 +1,48 @@ +{% extends 'base.html' %} + +{% block title %}RIGS Profile {{object.pk}}{% endblock %} + +{% block content %} +
+
+

{{object.name}}

+
+ {% if object.pk == user.pk %} +
+ +
+ {% endif %} +
+
+
First Name
+
{{object.first_name}}
+ +
Last Name
+
{{object.last_name}}
+ +
Email
+
{{object.email}}
+ +
Last Login
+
{{object.last_login}}
+ +
Date Joined
+
{{object.date_joined}}
+ +
Initials
+
{{object.initials}}
+ +
Phone
+
{{object.phone}}
+
+
+
+
+ +
+
+{% endblock %} \ No newline at end of file diff --git a/RIGS/templates/RIGS/profile_form.html b/RIGS/templates/RIGS/profile_form.html new file mode 100644 index 00000000..baa33424 --- /dev/null +++ b/RIGS/templates/RIGS/profile_form.html @@ -0,0 +1,71 @@ +{% extends 'base.html' %} +{% load widget_tweaks %} + +{% block title %}Update Profile {{object.name}}{% endblock %} + +{% block content %} +
+
+ {% include 'form_errors.html' %} +

Update Profile

+
+
{% csrf_token %} +
+ + +
+ {% render_field form.first_name class+="form-control" placeholder=form.first_name.label %} +
+
+ +
+ + +
+ {% render_field form.last_name class+="form-control" placeholder=form.last_name.label %} +
+
+ +
+ + +
+ {% render_field form.email type="email" class+="form-control" placeholder=form.email.label %} +
+
+ +
+ + +
+ {% render_field form.initials class+="form-control" placeholder=form.initials.label %} +
+
+ +
+ + +
+ {% render_field form.phone type="tel" class+="form-control" placeholder=form.phone.label %} +
+
+ +
+ +
+
+
+ + +
+
+{% endblock %} \ No newline at end of file diff --git a/RIGS/urls.py b/RIGS/urls.py index d50b78cb..27c932f9 100644 --- a/RIGS/urls.py +++ b/RIGS/urls.py @@ -106,6 +106,14 @@ 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\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 url(r'^api/(?P\w+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"), url(r'^api/(?P\w+)/(?P\d+)/$', (views.SecureAPIRequest.as_view()), name="api_secure"), diff --git a/RIGS/views.py b/RIGS/views.py index eb9f0b24..7c97c3b9 100644 --- a/RIGS/views.py +++ b/RIGS/views.py @@ -9,7 +9,7 @@ from django.core import serializers import simplejson 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 @@ -257,4 +257,30 @@ class SecureAPIRequest(generic.View): json = simplejson.dumps(results[:20]) return HttpResponse(json, content_type="application/json") # Always json - return HttpResponse(model) \ No newline at end of file + 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 \ No newline at end of file diff --git a/templates/base.html b/templates/base.html index 00b8c183..496d372b 100644 --- a/templates/base.html +++ b/templates/base.html @@ -76,18 +76,22 @@ {% else %}