diff --git a/symposion/sponsorship/urls.py b/symposion/sponsorship/urls.py index 52ccdaae..e5d32bb0 100644 --- a/symposion/sponsorship/urls.py +++ b/symposion/sponsorship/urls.py @@ -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\d+)/$", "sponsor_detail", name="sponsor_detail"), ) diff --git a/symposion/sponsorship/views.py b/symposion/sponsorship/views.py index 54782863..0e6e8386 100644 --- a/symposion/sponsorship/views.py +++ b/symposion/sponsorship/views.py @@ -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) diff --git a/symposion/templates/sponsorship/add.html b/symposion/templates/sponsorship/add.html new file mode 100644 index 00000000..afb91b8a --- /dev/null +++ b/symposion/templates/sponsorship/add.html @@ -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 %} +
+ {% csrf_token %} + {% trans "Add a Sponsor" %} + {{ form|as_bootstrap }} +
+ + Cancel +
+
+ +{% endblock %} diff --git a/symposion/templates/sponsorship/list.html b/symposion/templates/sponsorship/list.html index a1cb6ce0..1c26e952 100644 --- a/symposion/templates/sponsorship/list.html +++ b/symposion/templates/sponsorship/list.html @@ -20,20 +20,22 @@

{{ level.name }}

{% for sponsor in level.sponsors %} -
-
-

- - {{ sponsor.name }} - -

+ {% if sponsor.website_logo %} +
+
+

+ + {{ sponsor.name }} + +

+
+
+
{{ sponsor.name }}
+

{{ sponsor.external_url }}

+

{{ sponsor.listing_text|urlize|linebreaks }}

+
-
-
{{ sponsor.name }}
-

{{ sponsor.external_url }}

-

{{ sponsor.listing_text|urlize|linebreaks }}

-
-
+ {% endif %} {% endfor %} {% endif %} {% endfor %}