Commit b2168cea authored by Daniel W Bond's avatar Daniel W Bond

per peoplefinder exception, added support to change name

parent 5e6ea6f3
# core django imports
from django import forms
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
class UserNameForm(forms.ModelForm):
class Meta:
model = User
fields = ['first_name', 'last_name']
{% extends 'layouts/base.html' %}
{% block title %}
SRCT Bookshare • Edit Name
{% endblock title %}
{% block content %}
<div class="page-header" id="banner">
<div class="row">
<div class="col-lg-12 text-center">
<h1><strong>SRCT</strong>&#8203;BOOKSHARE</h1>
<p class="lead text-center"><strong>Edit Your Name</strong></p>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8 col-md-offset-2">
<div class="panel panel-default">
<div class="panel-heading">
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="Submit" class="btn btn-primary" />
<input type="cancel" value="Never Mind" class="btn btn-default" onclick="history.back()"/>
</form>
</div>
</div>
</div>
</div>
{% endblock content %}
# core django imports
from django.conf.urls import patterns, url
from django.views.decorators.cache import cache_page
# imports from your apps
from .views import DetailStudent, StudentRatings
from .views import DetailStudent, StudentRatings, UpdateStudent
urlpatterns = patterns('',
url(r'^name-change/$',
UpdateStudent.as_view(), name='name_change'),
url(r'^(?P<slug>[\w-]+)/$',
cache_page(60 * 2)(DetailStudent.as_view()), name='profile'),
DetailStudent.as_view(), name='profile'),
url(r'^(?P<slug>[\w-]+)/ratings/$',
cache_page(60 * 2)(StudentRatings.as_view()), name='ratings'),
StudentRatings.as_view(), name='ratings'),
)
# core django imports
from django.views.generic import DetailView
from django.views.generic import DetailView, FormView
from django.core.urlresolvers import reverse
# third-party imports
from braces.views import LoginRequiredMixin
from django.db.models import Sum
from ratelimit.decorators import ratelimit
# imports from your apps
from .models import Student
from .forms import UserNameForm
from lookouts.models import Lookout
from trades.models import Listing, Bid, Rating
......@@ -44,6 +47,37 @@ class DetailStudent(LoginRequiredMixin, DetailView):
return context
class UpdateStudent(LoginRequiredMixin, FormView):
template_name = 'update_student.html'
form_class = UserNameForm
login_url = 'login'
def get_context_data(self, **kwargs):
context = super(UpdateStudent, self).get_context_data(**kwargs)
form = UserNameForm()
form.fields['first_name'].initial = self.request.user.first_name
form.fields['last_name'].initial = self.request.user.last_name
context['form'] = form
return context
def form_valid(self, form):
self.request.user.first_name = form.instance.first_name
self.request.user.last_name = form.instance.last_name
self.request.user.save()
return super(UpdateStudent, self).form_valid(form)
@ratelimit(key='user', rate='5/m', method='POST', block=True)
@ratelimit(key='user', rate='10/day', method='POST', block=True)
def post(self, request, *args, **kwargs):
return super(UpdateStudent, self).post(request, *args, **kwargs)
def get_success_url(self):
return reverse('profile',
kwargs={'slug': self.request.user.student.slug})
class StudentRatings(LoginRequiredMixin, DetailView):
model = Student
template_name = 'ratings.html'
......
......@@ -20,14 +20,15 @@ SRCT Bookshare &bull; Privacy Policy
<p>
Listings posted on GMU Bookshare are instantly visible to all GMU
students, as well as information such as comments and bids made on
other user's listings, and transaction histories, ratings, feedback
other user's listings, and exchange histories, ratings, feedback
shown as part of a user's profile. Your real name and email adddress
accompany your profile information, through GMU's authentication.
</p>
<p>
Your profile information is as provided through the university, and
as of now we are unable to make any changes to your name, except as
changed by the university.
Your profile information is as provided through the university, however
you may change your name via your student page. Please be responsible
adults. Your username however cannot be changed except through the
registrar's office. Contact the ITU Support Center for details.
</p>
<h2>What data do we collect?</h2>
<p>
......@@ -73,11 +74,13 @@ SRCT Bookshare &bull; Privacy Policy
<a href="https://aws.amazon.com/privacy/">privacy policy here</a>.
</p>
<p>
As of now, many of your interactions with the site, such as
transactions, can't be removed by user. Special exceptions of course
will be made per as involation of GMU's responsible use of computing
or order, even upon graduation or other termination of relationship
with the university and the cessation of your full access GMU account.
As of now, many of your interactions with the site, such as listings,
exchanges, and bids can't be removed by the user. We will work to
responsibly add this feature in future releases. Special exceptions of
course will be made as in volation of GMU's responsible use of
computing or an order. Your information will not be removed upon
graduation or other termination of relationship with the university and
the cessation of your full access Mason account.
</p>
</div>
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment