-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from jandd/sponsoring-app
Sponsoring app
- Loading branch information
Showing
30 changed files
with
932 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_app_config = 'sponsoring.apps.SponsoringConfig' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from django import forms | ||
from django.contrib import admin | ||
from ordered_model.admin import OrderedTabularInline | ||
|
||
from sponsoring.models import SponsoringPackageItem, SponsoringPackage | ||
|
||
|
||
class SponsoringPackageItemForm(forms.ModelForm): | ||
class Meta: | ||
widgets = {'description': forms.Textarea(attrs={'rows': 1}), } | ||
|
||
|
||
class SponsoringPackageItemTabularInline(OrderedTabularInline): | ||
model = SponsoringPackageItem | ||
fields = ( | ||
'name', 'description', 'is_header', 'order', 'move_up_down_links',) | ||
readonly_fields = ('order', 'move_up_down_links',) | ||
extra = 1 | ||
ordering = ('order',) | ||
form = SponsoringPackageItemForm | ||
|
||
|
||
@admin.register(SponsoringPackage) | ||
class SponsoringPackageAdmin(admin.ModelAdmin): | ||
list_display = ('package_type', 'event', 'pricing',) | ||
list_filter = ('event',) | ||
inlines = (SponsoringPackageItemTabularInline,) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
from django.apps import AppConfig | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class SponsoringConfig(AppConfig): | ||
name = 'sponsoring' | ||
verbose_name = _('Sponsor Management') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from cms.app_base import CMSApp | ||
from cms.apphook_pool import apphook_pool | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
@apphook_pool.register | ||
class SponsoringApphook(CMSApp): | ||
name = _('Sponsoring') | ||
|
||
def get_urls(self, page=None, language=None, **kwargs): | ||
return ['sponsoring.urls'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
from crispy_forms.helper import FormHelper | ||
from crispy_forms.layout import Div, Field, HTML, Layout, Submit | ||
from django import forms | ||
from django.urls import reverse | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
|
||
class SponsoringContactForm(forms.Form): | ||
organization = forms.CharField( | ||
label=_('Your organization'), max_length=100) | ||
email = forms.EmailField(label=_('Contact email address')) | ||
body = forms.CharField( | ||
label=_('Your request'), widget=forms.Textarea(attrs={'rows': 5})) | ||
sponsoring_options = forms.MultipleChoiceField( | ||
label=_('Interested in sponsoring packages'), | ||
widget=forms.CheckboxSelectMultiple()) | ||
|
||
event = None | ||
|
||
def get_possible_choices(self): | ||
choices = [] | ||
for package in self.event.sponsoringpackage_set.all(): | ||
choices.append(( | ||
package.package_type, | ||
package.get_type_label())) | ||
choices.append((-1, _('Custom'))) | ||
return choices | ||
|
||
def __init__(self, **kwargs): | ||
self.event = kwargs.pop('event') | ||
super().__init__(**kwargs) | ||
self.fields['sponsoring_options'].choices = self.get_possible_choices() | ||
self.helper = FormHelper() | ||
self.helper.form_action = reverse( | ||
'sponsoring_view', kwargs={'event': self.event.slug}) | ||
self.helper.layout = Layout( | ||
Div( | ||
Div( | ||
Div( | ||
HTML('<h1>{}</h1>'.format(_('Sponsoring request'))), | ||
css_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
), | ||
Div( | ||
Field( | ||
'organization', | ||
wrapper_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
), | ||
Div( | ||
Field( | ||
'email', | ||
wrapper_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
), | ||
Div( | ||
Field( | ||
'sponsoring_options', | ||
wrapper_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
), | ||
Div( | ||
Field( | ||
'body', | ||
wrapper_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
), | ||
Div( | ||
Div( | ||
Submit( | ||
'submit', _('Send sponsoring request'), | ||
css_class='m-0 btn btn-primary', | ||
), | ||
css_class='offset-lg-2 col-lg-8 col-12', | ||
), | ||
css_class='form-row' | ||
) | ||
) | ||
) |
Oops, something went wrong.