Skip to content

Commit

Permalink
got sponsorship app flow working, adding missing templates, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
jtauber committed Jul 13, 2012
1 parent b9fe28b commit 9d36766
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 16 deletions.
35 changes: 35 additions & 0 deletions fixtures/sponsor_levels.json
@@ -0,0 +1,35 @@
[
{
"pk": 1,
"model": "sponsorship.sponsorlevel",
"fields": {
"conference": 1,
"description": "",
"cost": 10000,
"name": "Gold",
"order": 0
}
},
{
"pk": 2,
"model": "sponsorship.sponsorlevel",
"fields": {
"conference": 1,
"description": "",
"cost": 5000,
"name": "Silver",
"order": 1
}
},
{
"pk": 3,
"model": "sponsorship.sponsorlevel",
"fields": {
"conference": 1,
"description": "",
"cost": 2000,
"name": "Bronze",
"order": 2
}
}
]
44 changes: 43 additions & 1 deletion symposion/sponsorship/models.py
Expand Up @@ -26,7 +26,7 @@ class Meta:
verbose_name_plural = _("sponsor levels") verbose_name_plural = _("sponsor levels")


def __unicode__(self): def __unicode__(self):
return u"%s %s" % (self.conference, self.name) return self.name


def sponsors(self): def sponsors(self):
return self.sponsor_set.filter(active=True).order_by("added") return self.sponsor_set.filter(active=True).order_by("added")
Expand Down Expand Up @@ -62,6 +62,48 @@ def get_absolute_url(self):
return reverse("sponsor_detail", kwargs={"pk": self.pk}) return reverse("sponsor_detail", kwargs={"pk": self.pk})
return reverse("sponsor_list") return reverse("sponsor_list")


def reset_benefits(self):
"""
Reset all benefits for this sponsor to the defaults for their
sponsorship level.
"""
level = None

try:
level = self.level
except SponsorLevel.DoesNotExist:
pass

allowed_benefits = []
if level:
for benefit_level in level.benefit_levels.all():
# Create all needed benefits if they don't exist already
sponsor_benefit, created = SponsorBenefit.objects.get_or_create(
sponsor=self, benefit=benefit_level.benefit)

# and set to default limits for this level.
sponsor_benefit.max_words = benefit_level.max_words
sponsor_benefit.other_limits = benefit_level.other_limits

# and set to active
sponsor_benefit.active = True

# @@@ We don't call sponsor_benefit.clean here. This means
# that if the sponsorship level for a sponsor is adjusted
# downwards, an existing too-long text entry can remain,
# and won't raise a validation error until it's next
# edited.
sponsor_benefit.save()

allowed_benefits.append(sponsor_benefit.pk)

# Any remaining sponsor benefits that don't normally belong to
# this level are set to inactive
self.sponsor_benefits.exclude(pk__in=allowed_benefits).update(active=False, max_words=None, other_limits="")

def send_coordinator_emails(self):
pass # @@@ should this just be done centrally?



BENEFIT_TYPE_CHOICES = [ BENEFIT_TYPE_CHOICES = [
("text", "Text"), ("text", "Text"),
Expand Down
22 changes: 22 additions & 0 deletions symposion_project/templates/_default_sidebar.html
@@ -0,0 +1,22 @@
{% load sponsorship_tags %}
{% load thumbnail %}

{% sponsor_levels as levels %}

<h2>Sponsors</h2>

<div class="sponsor-list">
{% for level in levels %}
{% if level.sponsors %}
<h3 style="margin-top: 3em;">{{ level.name }}</h3>

{% for sponsor in level.sponsors %}
<div style="margin: 10px 0;">
<a href="{{ sponsor.external_url }}">
<img src="{% thumbnail sponsor.website_logo '100x60' %}" alt="{{ sponsor.name }}" />
</a>
</div>
{% endfor %}
{% endif %}
{% endfor %}
</div>
4 changes: 2 additions & 2 deletions symposion_project/templates/dashboard.html
Expand Up @@ -81,7 +81,7 @@ <h4>Proposals you have been invited to join</h4>
<section id="dashboard_sponsorship" class="dashboard-section well"> <section id="dashboard_sponsorship" class="dashboard-section well">
<h3>{% trans "Sponsorship" %}</h3> <h3>{% trans "Sponsorship" %}</h3>
{% if not user.sponsorships.exists %} {% if not user.sponsorships.exists %}
<a href="{# {% url sponsor_apply %} #}" class="btn"> <a href="{% url sponsor_apply %}" class="btn">
Apply to be a sponsor Apply to be a sponsor
</a> </a>
{% else %} {% else %}
Expand All @@ -90,7 +90,7 @@ <h4>Your Sponsorship</h4>
{% for sponsorship in user.sponsorships.all %} {% for sponsorship in user.sponsorships.all %}
<li> <li>
{% if sponsorship.active %} {% if sponsorship.active %}
<a href="{# {% url sponsor_detail sponsorship.pk %}" #}><b>{{ sponsorship.name }}</b></a> <a href="{% url sponsor_detail sponsorship.pk %}"><b>{{ sponsorship.name }}</b></a>
({{ sponsorship.level }}) ({{ sponsorship.level }})
{% else %} {% else %}
<b>{{ sponsorship.name }}</b> <b>{{ sponsorship.name }}</b>
Expand Down
25 changes: 12 additions & 13 deletions symposion_project/templates/site_base.html
Expand Up @@ -66,20 +66,19 @@ <h2><a href="{% url home %}"><span style="font-weight: 200;">Some amazing locati
{# {% sitetree_breadcrumbs from "main" %} #} {# {% sitetree_breadcrumbs from "main" %} #}
{# {% endblock %} #} {# {% endblock %} #}


<div class="row"> {% block body_outer %}
<div class="span9"> <div class="row">
{% block body %} <div class="span9">
{% endblock %} {% block body %}
</div> {% endblock %}
<div class="span3"> </div>
<h4>Sponsors</h4> <div class="span3">
<img src="http://placekitten.com/g/200/100"></img><br /><br /> {% block sidebar %}
<img src="http://placekitten.com/g/200/101"></img><br /><br /> {% include "_default_sidebar.html" %}
<img src="http://placekitten.com/g/200/98"></img><br /><br /> {% endblock %}
<img src="http://placekitten.com/g/200/99"></img><br /><br /> </div>
<img src="http://placekitten.com/g/200/102"></img><br /><br />
</div> </div>
</div> {% endblock %}
</div> </div>
{% endblock %} {% endblock %}


Expand Down
28 changes: 28 additions & 0 deletions symposion_project/templates/sponsorship/apply.html
@@ -0,0 +1,28 @@
{% extends "site_base.html" %}

{% load bootstrap_tags %}
{% load i18n %}
{% load boxes_tags %}

{% block head_title %}{% trans "Apply to be a Sponsor" %}{% endblock %}

{% block body_class %}sponsors{% endblock %}

{% block body %}

{% box "sponsorship-apply" %}

<form method="POST" action="" class="form-horizontal">
{% csrf_token %}
<legend>{% trans "Apply to Be a Sponsor" %}</legend>
{{ form|as_bootstrap }}
<div class="form-actions">
<input class="btn btn-primary" type="submit" value="Apply" />
<a class="btn" href="{% url dashboard %}">Cancel</a>
<p class="help-block">
<small>By submitting this sponsor application you are agreeing to the <a href="{% url cms_page "sponsor/terms/" %}" target="_blank">terms and conditions</a>.</small>
</p>
</div>
</form>

{% endblock %}
40 changes: 40 additions & 0 deletions symposion_project/templates/sponsorship/detail.html
@@ -0,0 +1,40 @@
{% extends "site_base.html" %}

{% load bootstrap_tags %}
{% load i18n %}

{% block head_title %}{{ sponsor }}{% endblock %}

{% block page_title %}{% trans "Sponsorship" %}{% endblock %}

{% block body %}
<h2>{{ sponsor.name }} ({{ sponsor.level }})</h2>

<form enctype="multipart/form-data" method="POST" action="" class="form-horizontal">
{% csrf_token %}
<fieldset>
{{ form|as_bootstrap }}
</fieldset>

<h3>{{ sponsor.level }} Sponsor Benefits</h3>

{{ formset.management_form }}
{{ formset.non_form_errors }}

{% for form in formset.forms %}
<div class="control-group">
<label class="control-label">{{ form.instance.benefit }}</label>
<div class="controls">
{{ form }}
<p class="help-block">{{ form.instance.benefit.description }}</p>
</div>
</div>
{% endfor %}

<div class="form-actions">
<input class="btn btn-primary" type="submit" value="Save" />
<a class="btn" href="{% url dashboard %}">Cancel</a>
</div>

</form>
{% endblock %}
43 changes: 43 additions & 0 deletions symposion_project/templates/sponsorship/list.html
@@ -0,0 +1,43 @@
{% extends "site_base.html" %}

{% load sponsorship_tags %}
{% load thumbnail %}
{% load i18n %}

{% block head_title %}{% trans "About Our Sponsors" %}{% endblock %}

{% block body_class %}sponsors{% endblock %}

{% sponsor_levels as levels %}

{% block body_outer %}
<div class="row">
<div class="span12">
<h1>{% trans "About Our Sponsors" %}</h1>
<a href="{% url cms_page "sponsors/prospectus/" %}" class="btn">Learn how to become a sponsor <span class="arrow"></span></a>

{% for level in levels %}
<h3>{{ level.name }}</h3>

<div class="row">
{% for sponsor in level.sponsors %}
<div class="span4">
<div class="sponsor" id="sponsor-{{ sponsor.id }}">
<div class="sponsor-content">
<h2>
<a href="{{ sponsor.external_url }}">
<img src="{% thumbnail sponsor.website_logo '150x80' %}" alt="{{ sponsor.name }}" />
</a>
</h2>
<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>
{% endfor %}
</div>
{% endfor %}
</div>
</div>
{% endblock %}
1 change: 1 addition & 0 deletions symposion_project/urls.py
Expand Up @@ -23,6 +23,7 @@
url(r"^dashboard/", symposion.views.dashboard, name="dashboard"), url(r"^dashboard/", symposion.views.dashboard, name="dashboard"),
url(r"^speaker/", include("symposion.speakers.urls")), url(r"^speaker/", include("symposion.speakers.urls")),
url(r"^proposals/", include("symposion.proposals.urls")), url(r"^proposals/", include("symposion.proposals.urls")),
url(r"^sponsors/", include("symposion.sponsorship.urls")),
url(r"^boxes/", include("symposion.boxes.urls")), url(r"^boxes/", include("symposion.boxes.urls")),
url(r"^markitup/", include("markitup.urls")), url(r"^markitup/", include("markitup.urls")),


Expand Down

0 comments on commit 9d36766

Please sign in to comment.