Skip to content

Commit

Permalink
added sponsor list view
Browse files Browse the repository at this point in the history
more edits to the sponsor templates
  • Loading branch information
JoeJasinski committed Sep 19, 2015
1 parent 257031e commit 0e14175
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 25 deletions.
4 changes: 0 additions & 4 deletions chipy_org/apps/meetings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
)


@python_2_unicode_compatible
class Venue(CommonModel):

def __str__(self):
Expand Down Expand Up @@ -80,7 +79,6 @@ def number_rsvps(self):
return self.rsvp_set.exclude(response='N').count()


@python_2_unicode_compatible
class Presentor(CommonModel):

def __str__(self):
Expand All @@ -103,7 +101,6 @@ def __str__(self):
)


@python_2_unicode_compatible
class Topic(CommonModel):

def __str__(self):
Expand All @@ -124,7 +121,6 @@ def __str__(self):
approved = models.BooleanField(default=False)


@python_2_unicode_compatible
class RSVP(CommonModel):

RSVP_CHOICES = (
Expand Down
8 changes: 6 additions & 2 deletions chipy_org/apps/sponsors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class MeetingSponsor(models.Model):
sponsor = models.ForeignKey("sponsors.Sponsor")
meeting = models.ForeignKey("meetings.Meeting")
meeting = models.ForeignKey("meetings.Meeting", related_name="meeting_sponsors")
about = models.TextField(u"About this sponsorship", blank=True, null=True)

def __str__(self):
Expand All @@ -17,6 +17,7 @@ def __str__(self):
class Meta:
verbose_name = "Meeting Sponsor"
verbose_name_plural = "Meeting Sponsors"
ordering = ["sponsor__name"]


class Sponsor(models.Model):
Expand All @@ -25,7 +26,10 @@ class Sponsor(models.Model):
slug = models.SlugField(max_length=80)
url = models.URLField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
logo = models.ImageField(upload_to="sponsor_logos", blank=True, null=True)
logo = models.ImageField(
upload_to="sponsor_logos", blank=True, null=True,
help_text=("All logos will be cropped to fit a 4 by 3 aspect ratio. "
"Resolution should be at minimum 400x300."))

def __str__(self):
return "{name}".format(name=self.name)
Expand Down
31 changes: 19 additions & 12 deletions chipy_org/apps/sponsors/templates/sponsors/sponsor_detail.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
{% extends "site_base.html" %}

{% load i18n staticfiles %}
{% load i18n staticfiles thumbnail %}

{% block head_title %}{% trans "Past Meetings" %}{% endblock %}

{% block body %}
<h2>Sponsored by:</h2>
<h2>ChiPy Sponsor</h2>

<h3>
{{ sponsor.name }}
</h3>
<div class="row">
<h3 class="span12">{{ sponsor.name }}</h3>
</row>
<div class="row">
{% if sponsor.logo %}
<img src="{{ sponsor.logo.url }}" alt="{{ sponsor.name }}">
{% endif %}
<p>
{{ sponsor.description }}
</p>
{% if sponsor.url %}
<p><a href="{{ sponsor.url }}">Visit Site</a></p>
{% thumbnail sponsor.logo "400x300" crop="center" as im %}
<div class="span4 sponsor-image"><a href="{{ sponsor.url }}">
<img src="{{ im.url }}" alt="{{ sponsor.name }}"></a></div>
{% endthumbnail %}
{% endif %}

<div class="span8">{{ sponsor.description }}
{% if sponsor.url %}
<div><a href="{{ sponsor.url }}">Visit Site</a></div>
{% endif %}
</div>

</div>

<hr>
{% endblock body %}
29 changes: 29 additions & 0 deletions chipy_org/apps/sponsors/templates/sponsors/sponsor_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "site_base.html" %}

{% load i18n staticfiles thumbnail %}

{% block head_title %}{% trans "Sponsor List" %}{% endblock %}

{% block body %}
<h2>ChiPy Sponsors</h2>

{% for sponsor in sponsors %}
<div class="row">

{% if sponsor.logo %}
{% thumbnail sponsor.logo "100x75" crop="center" as im %}
<div class="span2 sponsor-image">
<a href="{% url 'sponsor_detail' sponsor.slug %}"><img src="{{ im.url }}" alt="{{ sponsor.name }}"></a>
</div>
{% endthumbnail %}
{% else %}
<div class="span2 sponsor-image">&nbsp;</div>
{% endif %}
<h4 class="span3">{{ sponsor.name }}</h4>
<div class="span6"><a href="{% url 'sponsor_detail' sponsor.slug %}">More Info</a></div>

</div>
<hr>
{% endfor %}

{% endblock body %}
5 changes: 4 additions & 1 deletion chipy_org/apps/sponsors/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
from django.conf.urls import *
from .views import SponsorDetailView
from .views import SponsorDetailView, SponsorListView


urlpatterns = patterns("",
url(r'^detail/(?P<slug>[\w]+)/$',
SponsorDetailView.as_view(), name='sponsor_detail'),
url(r'^list/$',
SponsorListView.as_view(), name='sponsor_list'),

)
11 changes: 10 additions & 1 deletion chipy_org/apps/sponsors/views.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
from django.shortcuts import render
from .models import Sponsor
from django.views.generic import DetailView
from django.views.generic import DetailView, ListView


class SponsorDetailView(DetailView):
model = Sponsor
context_object_name = "sponsor"
template_name = "sponsors/sponsor_detail.html"


class SponsorListView(ListView):
model = Sponsor
context_object_name = "sponsors"
template_name = "sponsors/sponsor_list.html"

def get_queryset(self):
return super(SponsorListView, self).get_queryset().order_by('name')
2 changes: 1 addition & 1 deletion chipy_org/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def env_list(key, defaults=[], delimiter=','):
'south',
'storages',
'tinymce',
'storages',
"sorl.thumbnail",

# theme
'django_forms_bootstrap',
Expand Down
1 change: 1 addition & 0 deletions chipy_org/templates/_footer.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% load i18n %}
<div><a href="{% url 'sponsor_list' %}">Sponsors</div>
<div class="legal">
{% trans "&copy; 2014 Chicago Python User Group" %}: {% trans "Source code available at " %}<a href="https://github.com/chicagopython/chipy.org">Github</a>
</div>
31 changes: 27 additions & 4 deletions chipy_org/templates/meetings/past_meetings.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{% extends "site_base.html" %}

{% load i18n staticfiles %}
{% load i18n staticfiles thumbnail %}

{% block head_title %}{% trans "Past Meetings" %}{% endblock %}

Expand All @@ -23,13 +23,36 @@ <h1>{{ meeting }}</h1>
{% endif %}
{% endfor %}

<div class="span12 sponsors">
{% for sponsor in meetings.sponsors.all %}
<div>{{ sponsor }}</div>
<div class="sponsors">
{% with meeting.meeting_sponsors.all as meeting_sponsors %}
{% if meeting_sponsors %}
This meeting sponsored by:
{% for meeting_sponsor in meeting_sponsors %}
<div class="row sponsor-block">
{% if meeting_sponsor.sponsor.logo %}
{% thumbnail meeting_sponsor.sponsor.logo "80x60" crop="center" as im %}
<div class="span2 sponsor-image">
<a href="{% url 'sponsor_detail' meeting_sponsor.sponsor.slug %}">
<img src="{{ im.url }}" alt="{{ meeting_sponsor.sponsor.name }}"></a>
</div>
{% endthumbnail %}
{% else %}
<div class="span2 sponsor-image">&nbsp;</div>
{% endif %}
<div class="span3 sponsor-name">
<a href="{% url 'sponsor_detail' meeting_sponsor.sponsor.slug %}">{{ meeting_sponsor.sponsor.name }}</a>
</div>
{% if meeting_sponsor.about %}
<div class="span6 sponsor-about">{{ meeting_sponsor.about }}</div>
{% endif %}
</div>
{% endfor %}
{% endif %}
{% endwith %}
</div>

{{meeting.number_rsvps}} {% trans " Python enthusiasts attended this meeting." %}
</div>
<hr>
{% endfor %}
{% endblock body %}
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ psycopg2==2.6.1
python-openid==2.2.5
requests==2.7.0
six==1.9.0
sorl-thumbnail==12.3
whitenoise==2.0.3
wsgiref==0.1.2
-e git+https://github.com/squarepegsys/django-flatpages-tinymce.git#egg=flatpages_tinymce

0 comments on commit 0e14175

Please sign in to comment.