user can now change marc preferences

pull/1/head
Andromeda Yelton 2013-07-23 12:23:04 -04:00
parent 1414ae5fa4
commit bb5c1079b6
7 changed files with 70 additions and 8 deletions

View File

@ -1159,7 +1159,8 @@ class UserProfile(models.Model):
marc_format = models.CharField(
max_length=6,
default = 'DIRECT',
choices = settings.MARC_CHOICES
choices = settings.MARC_CHOICES,
verbose_name="MARC record link targets"
)
goodreads_user_id = models.CharField(max_length=32, null=True, blank=True)
@ -1170,7 +1171,7 @@ class UserProfile(models.Model):
avatar_source = models.PositiveSmallIntegerField(null = True, default = GRAVATAR,
choices=((NO_AVATAR,'No Avatar, Please'),(GRAVATAR,'Gravatar'),(TWITTER,'Twitter'),(FACEBOOK,'Facebook')))
def __unicode__(self):
return self.user.username

View File

@ -588,4 +588,9 @@ class MARCUngluifyForm(forms.Form):
break
if not ebooks:
raise forms.ValidationError('Please add at least one unglued ebook link to THIS EDITION through the work or admin page before creating a MARC record.')
return self.cleaned_data
return self.cleaned_data
class MARCFormatForm(forms.ModelForm):
class Meta:
model = UserProfile
fields = ('marc_format',)

View File

@ -12,7 +12,7 @@
<li>... or <a href="{% url manage_account %}">manage your pledges and payment info</a>?</li>
<li>... or <a href="{% url regluit.frontend.views.edit_user %}">change your username</a>?</li>
<li>... or <a href="{% url notification_notice_settings %}">manage your contact preferences</a>?</li>
<li>... or <a href="{% url kindle_config %}">add or change a Send-to-Kindle email?</a>?</li>
<li>... or <a href="{% url kindle_config %}">add or change a Send-to-Kindle email</a>?</li>
</ul>
</div>
{% endblock %}

View File

@ -109,7 +109,8 @@ $j(document).ready(function(){
<li>Want to <a href="{% url auth_password_change %}">change your password</a>?</li>
<li>... or <a href="{% url notification_notice_settings %}">manage your contact preferences</a>?</li>
<li>... or <a href="{% url email_change %}">change your email address</a>?</li>
<li>... or <a href="{% url regluit.frontend.views.edit_user %}">change your username </a>?</li>
<li>... or <a href="{% url regluit.frontend.views.edit_user %}">change your username</a>?</li>
<li>... or <a href="{% url marc_config %}">change your MARC record preferences</a>?</li>
<li>... or <a href="{% url kindle_config %}">add or change a Send-to-Kindle email</a>?</li>
</ul>
{% endblock %}

View File

@ -0,0 +1,32 @@
{% extends "email_change/base.html" %}
{% block extra_extra_head %}
{{ block.super }}
<style type="text/css">
#login {
width: auto;
display: block;
}
</style>
{% endblock %}
{% block title %}Change your MARC record preferences{% endblock %}
{% block ce_content %}
{% if messages %}
<ul class="messages">
{% for message in messages %}
<li{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
Your current MARC record link target preference is:<br />
{{ request.user.profile.get_marc_format_display }}
<form method="post" action="{% url marc_config %}">
{% csrf_token %}
{{ form }}
<br />
<input type="submit" value="Change" />
</form>
{% endblock %}

View File

@ -34,7 +34,8 @@ from regluit.frontend.views import (
kindle_config,
send_to_kindle,
send_to_kindle_graceful,
MARCUngluifyView
MARCUngluifyView,
MARCConfigView
)
urlpatterns = patterns(
@ -134,6 +135,7 @@ urlpatterns = patterns(
url(r"^send_to_kindle/result/(?P<message>\d)/$", "send_to_kindle_graceful", name="send_to_kindle_graceful"),
url(r"^marc/$", "marc", name="marc"),
url(r"^marc/ungluify/$", login_required(MARCUngluifyView.as_view()), name="MARCUngluify"),
url(r"^accounts/edit/marc_config/$", login_required(MARCConfigView.as_view()), name="marc_config"),
)
if settings.DEBUG:

View File

@ -104,7 +104,8 @@ from regluit.frontend.forms import (
AuthForm,
PressForm,
KindleEmailForm,
MARCUngluifyForm
MARCUngluifyForm,
MARCFormatForm
)
from regluit.payment import baseprocessor, stripelib
@ -2640,4 +2641,24 @@ class MARCUngluifyView(FormView):
self.request,
"Sorry, couldn't parse that file."
)
return super(MARCUngluifyView,self).form_valid(form)
return super(MARCUngluifyView,self).form_valid(form)
class MARCConfigView(FormView):
template_name = 'marc_config.html'
form_class = MARCFormatForm
success_url = reverse_lazy('marc')
def form_valid(self, form):
marc_format = form.cleaned_data['marc_format']
profile = self.request.user.profile
profile.marc_format = marc_format
profile.save()
messages.success(
self.request,
"Your preferences have been changed."
)
if reverse('marc_config', args=[]) in self.request.META['HTTP_REFERER']:
return HttpResponseRedirect(reverse('marc_config', args=[]))
else:
return super(MARCConfigView, self).form_valid(form)