first cut at UI for unglue.it admins to create rights holders and delegate ownership

pull/1/head
eric 2011-11-14 23:28:55 -05:00
parent 4e2e460903
commit 0328430169
5 changed files with 60 additions and 3 deletions

View File

@ -1,10 +1,14 @@
from django import forms
from django.db import models
from regluit.core.models import UserProfile
from regluit.core.models import UserProfile, RightsHolder
from django.contrib.auth.models import User
from django.utils.translation import ugettext_lazy as _
from decimal import Decimal as D
class RightsHolderForm(forms.ModelForm):
class Meta:
model = RightsHolder
class ProfileForm(forms.ModelForm):
clear_facebook=forms.BooleanField(required=False)
clear_twitter=forms.BooleanField(required=False)

View File

@ -0,0 +1,9 @@
{% extends "basedocumentation.html" %}
{% block doccontent %}
<h1>Admin Users Only</h1>
<p>This function is only available to Unglue.it administration.</p>
{% endblock %}

View File

@ -0,0 +1,22 @@
{% extends "basedocumentation.html" %}
{% block doccontent %}
<h1>Rights Holder Admin</h1>
<h2> Create New Rights Holder </h2>
<form method="POST" action="#">
{% csrf_token %}
{{ form.as_p }}
<input type="submit" name="submit" value="Create" id="submit">
</form>
</form>
<h2> Accepted Rights Holders </h2>
{% for rights_holder in rights_holders %}
<h3>{{ rights_holder.rights_holder_name }}</h3>
PSA #: {{ rights_holder.id }}<br/>
email: {{ rights_holder.email }}<br/>
owner: <a href="{% url supporter supporter_username=rights_holder.owner %}">{{ rights_holder.owner }}</a><br/>
{% endfor %}
{% endblock %}

View File

@ -17,6 +17,7 @@ urlpatterns = patterns(
name="privacy"),
url(r"^rightsholders/$", TemplateView.as_view(template_name="rhtools.html"),
name="rightsholders"),
url(r"^rh_admin/$", "rh_admin", name="rh_admin"),
url(r"^faq/$", TemplateView.as_view(template_name="faq.html"),
name="faq"),
url(r"^wishlist/$", "wishlist", name="wishlist"),

View File

@ -24,7 +24,7 @@ from regluit.core import models, bookloader
from regluit.core import userlists
from regluit.core.search import gluejar_search
from regluit.core.goodreads import GoodreadsClient
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm
from regluit.frontend.forms import UserData, ProfileForm, CampaignPledgeForm, GoodreadsShelfLoadingForm, RightsHolderForm
from regluit.payment.manager import PaymentManager
from regluit.payment.parameters import TARGET_TYPE_CAMPAIGN
@ -87,6 +87,25 @@ def pledge(request,work_id):
return render(request,'pledge.html',{'work':work,'campaign':campaign, 'premiums':premiums, 'form':form})
def rh_admin(request):
if not is_admin(request.user):
return render(request, "admins_only.html")
if request.method == 'POST':
form = RightsHolderForm(data=request.POST)
if form.is_valid():
form.save()
else:
form = RightsHolderForm()
rights_holders = models.RightsHolder.objects.all()
context = { 'request': request, 'rights_holders': rights_holders, 'form': form }
return render(request, "rights_holders.html", context)
def is_admin(user):
for name,email in settings.ADMINS :
if email == user.email :
return True
return False
def supporter(request, supporter_username, template_name):
supporter = get_object_or_404(User, username=supporter_username)
wishlist = supporter.wishlist
@ -168,6 +187,8 @@ def edit_user(request):
request.user.save()
return HttpResponseRedirect(reverse('home')) # Redirect after POST
return render(request,'registration/user_change_form.html', {'form': form},)
def search(request):
q = request.GET.get('q', None)
results = gluejar_search(q)