allow staff to add sponsors directly via interface
This commit is contained in:
parent
1f98a6a754
commit
0f32fdcb74
4 changed files with 61 additions and 15 deletions
|
@ -5,5 +5,6 @@ from django.views.generic.simple import direct_to_template
|
|||
urlpatterns = patterns("symposion.sponsorship.views",
|
||||
url(r"^$", direct_to_template, {"template": "sponsorship/list.html"}, name="sponsor_list"),
|
||||
url(r"^apply/$", "sponsor_apply", name="sponsor_apply"),
|
||||
url(r"^add/$", "sponsor_add", name="sponsor_add"),
|
||||
url(r"^(?P<pk>\d+)/$", "sponsor_detail", name="sponsor_detail"),
|
||||
)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from django.http import Http404
|
||||
from django.shortcuts import render_to_response, redirect, get_object_or_404
|
||||
from django.template import RequestContext
|
||||
|
||||
|
@ -23,6 +24,26 @@ def sponsor_apply(request):
|
|||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@login_required
|
||||
def sponsor_add(request):
|
||||
if not request.user.is_staff:
|
||||
raise Http404()
|
||||
|
||||
if request.method == "POST":
|
||||
form = SponsorApplicationForm(request.POST, user=request.user)
|
||||
if form.is_valid():
|
||||
sponsor = form.save(commit=False)
|
||||
sponsor.active = True
|
||||
sponsor.save()
|
||||
return redirect("dashboard")
|
||||
else:
|
||||
form = SponsorApplicationForm(user=request.user)
|
||||
|
||||
return render_to_response("sponsorship/add.html", {
|
||||
"form": form,
|
||||
}, context_instance=RequestContext(request))
|
||||
|
||||
|
||||
@login_required
|
||||
def sponsor_detail(request, pk):
|
||||
sponsor = get_object_or_404(Sponsor, pk=pk)
|
||||
|
@ -44,9 +65,9 @@ def sponsor_detail(request, pk):
|
|||
form.save()
|
||||
formset.save()
|
||||
|
||||
messages.success(request, "Your sponsorship application has been submitted!")
|
||||
messages.success(request, "Sponsorship details have been updated")
|
||||
|
||||
return redirect(request.path)
|
||||
return redirect("dashboard")
|
||||
else:
|
||||
form = SponsorDetailsForm(instance=sponsor)
|
||||
formset = SponsorBenefitsFormSet(**formset_kwargs)
|
||||
|
|
22
symposion/templates/sponsorship/add.html
Normal file
22
symposion/templates/sponsorship/add.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
{% extends "site_base.html" %}
|
||||
|
||||
{% load bootstrap_tags %}
|
||||
{% load i18n %}
|
||||
{% load boxes_tags %}
|
||||
|
||||
{% block head_title %}{% trans "Add a Sponsor" %}{% endblock %}
|
||||
|
||||
{% block body_class %}sponsors{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<form method="POST" action="{% url sponsor_add %}" class="form-horizontal">
|
||||
{% csrf_token %}
|
||||
<legend>{% trans "Add a Sponsor" %}</legend>
|
||||
{{ form|as_bootstrap }}
|
||||
<div class="form-actions">
|
||||
<input class="btn btn-primary" type="submit" value="Add" />
|
||||
<a class="btn" href="{% url dashboard %}">Cancel</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -20,20 +20,22 @@
|
|||
<h3>{{ level.name }}</h3>
|
||||
|
||||
{% for sponsor in level.sponsors %}
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<h2>
|
||||
<a href="{{ sponsor.external_url }}">
|
||||
<img src="{% thumbnail sponsor.website_logo '150x80' %}" alt="{{ sponsor.name }}" />
|
||||
</a>
|
||||
</h2>
|
||||
{% if sponsor.website_logo %}
|
||||
<div class="row">
|
||||
<div class="span2">
|
||||
<h2>
|
||||
<a href="{{ sponsor.external_url }}">
|
||||
<img src="{% thumbnail sponsor.website_logo '150x80' %}" alt="{{ sponsor.name }}" />
|
||||
</a>
|
||||
</h2>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<h5>{{ sponsor.name }}</h5>
|
||||
<p><a href="{{ sponsor.external_url }}">{{ sponsor.external_url }}</a></p>
|
||||
<p>{{ sponsor.listing_text|urlize|linebreaks }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<h5>{{ sponsor.name }}</h5>
|
||||
<p><a href="{{ sponsor.external_url }}">{{ sponsor.external_url }}</a></p>
|
||||
<p>{{ sponsor.listing_text|urlize|linebreaks }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
|
Loading…
Reference in a new issue