diff --git a/sponsors/templates/sponsors/view_sponsors.html b/sponsors/templates/sponsors/view_sponsors.html index fdcaa8d3b9a399477935f14c6cb022469edc81b9..3c39bd766aead4fb9b82f44358c2c985690f8412 100644 --- a/sponsors/templates/sponsors/view_sponsors.html +++ b/sponsors/templates/sponsors/view_sponsors.html @@ -1,5 +1,5 @@ {% extends "usta/base.html" %} -{% load staticfiles %} +{% load staticfiles htmleditor_tags %} {% block title %}{{ block.super }} | Sponsors{% endblock %} @@ -59,15 +59,21 @@ {% endif %} </div> <div id="individual-patrons" class="content"> - <table> - {% for individual in individuals %} - <tr> - <td> - {{ individual }} - </td> - </tr> - {% endfor %} - </table> + {% if individual_patrons %} + {% if perms.htmleditor.change_document %}<h1><a href="{% url 'admin:htmleditor_document_change' individual_patrons.pk %}?next={{ request.get_full_path|urlencode }}">Edit {{ individual_patrons.name }} <img alt="Pencil" title="Edit" src="{% static 'usta/edit.png' %}"></a></h1>{% endif %} + + {% docreplace individual_patrons.content %} + {% else %} + <table> + {% for individual in individuals %} + <tr> + <td> + {{ individual }} + </td> + </tr> + {% endfor %} + </table> + {% endif %} </div> <div id="advertisers" class="content"> <ol class="company-list"> diff --git a/sponsors/views.py b/sponsors/views.py index 3f1811efaa314af75f88a1f1ce0aa946f7c5e8b6..6a5aed61c5f6d40244a71a02f97d5fc9c260ff35 100644 --- a/sponsors/views.py +++ b/sponsors/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render from django.template import RequestContext from sponsors.models import Company, Individual +from usta.models import get_site_settings def view_sponsors(request): @@ -19,6 +20,12 @@ def view_sponsors(request): sponsor_level=Company.LEVEL_CORP_PATRON_STANDARD) advertisers = Company.objects.filter(advertiser=True) individuals = Individual.objects.all() + + site_settings = get_site_settings() + + individual_patrons = site_settings.get_setting( + 'individual_patrons_document', None) + return render(request, 'sponsors/view_sponsors.html', { 'sponsors_1': sponsors_1, 'sponsors_2': sponsors_2, @@ -27,6 +34,7 @@ def view_sponsors(request): 'patrons_2': patrons_2, 'advertisers': advertisers, 'individuals': individuals, + 'individual_patrons': individual_patrons, 'title': 'Sponsors', 'show_generic': True, }) diff --git a/usta/admin.py b/usta/admin.py index 2a69641e632d6374043703c7be1ed2153ea498e7..87f9df868b4ff381455f84ebe1205a085874e473 100644 --- a/usta/admin.py +++ b/usta/admin.py @@ -323,7 +323,7 @@ class SiteSettingsAdmin(SingleInstanceAdminMixin, admin.ModelAdmin): 'fields': ('volunteer_node',) }), ('Sponsors', { - 'fields': ('sponsor_node',) + 'fields': ('sponsor_node', 'individual_patrons_document') }), ('Home Page', { 'fields': ('home_page_document',) diff --git a/usta/migrations/0021_sitesettings_individual_patrons_document.py b/usta/migrations/0021_sitesettings_individual_patrons_document.py new file mode 100644 index 0000000000000000000000000000000000000000..a37602cecc818cea4e8dc7477423bb155b9aa4e9 --- /dev/null +++ b/usta/migrations/0021_sitesettings_individual_patrons_document.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.1 on 2016-06-24 01:41 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('htmleditor', '0024_banner_sort'), + ('usta', '0020_tournamentdate_end_date'), + ] + + operations = [ + migrations.AddField( + model_name='sitesettings', + name='individual_patrons_document', + field=models.ForeignKey(blank=True, help_text='The document that is shown on the sponsors page for individual patrons.', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='htmleditor.Document'), + ), + ] diff --git a/usta/models.py b/usta/models.py index 938e4b994c29d782eb0215bb4039aa39ea25b7b8..376f3f6f8470655644b2b05172809fa43c462e89 100644 --- a/usta/models.py +++ b/usta/models.py @@ -553,6 +553,12 @@ class SiteSettings(GetSettingMixin, SingleInstanceMixin, models.Model): blank=True, null=True, help_text="The node that contains how sponsors can sign up. This link is shown on the sponsor banners where the level is.", related_name='+') + individual_patrons_document = models.ForeignKey('htmleditor.Document', + models.SET_NULL, + blank=True, null=True, + help_text="The document that is shown on the sponsors page for " + + "individual patrons.", + related_name='+') # -- Home Page Settings --------------------------------------------------- home_page_document = models.ForeignKey('htmleditor.Document', models.SET_NULL,