-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 735134d
Showing
20 changed files
with
526 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*.pyc | ||
*.egg-info | ||
dist/ |
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 @@ | ||
Copyright (c) 2015, Takeflight | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
* Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
* Neither the name of wagtailjobs nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
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,4 @@ | ||
include LICENSE | ||
include README.rst | ||
|
||
recursive-include wagtailpolls/templates * |
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,24 @@ | ||
=============== | ||
wagtailpolls | ||
=============== | ||
|
||
A plugin for Wagtail that provides polling functionality | ||
`Documentation on ReadTheDocs <https://wagtailpolls.readthedocs.org/en/latest/>`_ | ||
|
||
Installing | ||
========== | ||
|
||
Install using pip:: | ||
|
||
pip install wagtailpolls | ||
|
||
It works with Wagtail 1.0b2 and upwards. | ||
|
||
Using | ||
===== | ||
|
||
Create poll models for your application that inherit from the relevant ``wagtailpolls`` models: | ||
|
||
.. code-block:: python | ||
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,2 @@ | ||
[metadata] | ||
description-file = README.rst |
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,46 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Install wagtailpolls using setuptools | ||
""" | ||
|
||
from wagtailpolls import __version__ | ||
|
||
with open('README.rst', 'r') as f: | ||
readme = f.read() | ||
|
||
try: | ||
from setuptools import setup, find_packages | ||
except ImportError: | ||
from ez_setup import use_setuptools | ||
use_setuptools() | ||
from setuptools import setup, find_packages | ||
|
||
setup( | ||
name='wagtailpolls', | ||
version=__version__, | ||
description='A polling plugin for the Wagtail CMS', | ||
long_description=readme, | ||
author='Takeflight', | ||
author_email='liam@takeflight.com.au', | ||
url='https://github.com/takeflight/wagtailpolls', | ||
|
||
install_requires=[ | ||
'wagtail>=1.0b2', | ||
], | ||
zip_safe=False, | ||
license='BSD License', | ||
|
||
packages=find_packages(), | ||
|
||
include_package_data=True, | ||
package_data={}, | ||
|
||
classifiers=[ | ||
'Environment :: Web Environment', | ||
'Intended Audience :: Developers', | ||
'Operating System :: OS Independent', | ||
'Programming Language :: Python', | ||
'Framework :: Django', | ||
'License :: OSI Approved :: BSD License', | ||
], | ||
) |
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 @@ | ||
__version__ = '0.1' |
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,16 @@ | ||
from django import forms | ||
|
||
|
||
class SearchForm(forms.Form): | ||
query = forms.CharField(required=False) | ||
|
||
|
||
class StatementForm(forms.Form): | ||
date_from = forms.DateField( | ||
required=False, | ||
widget=forms.DateInput(attrs={'placeholder': 'Date from'}) | ||
) | ||
date_to = forms.DateField( | ||
required=False, | ||
widget=forms.DateInput(attrs={'placeholder': 'Date to'}) | ||
) |
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,23 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
import django.utils.timezone | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Poll', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, verbose_name='ID', serialize=False)), | ||
('email', models.EmailField(blank=True, max_length=254)), | ||
('issue_date', models.DateTimeField(default=django.utils.timezone.now, verbose_name='Issue date')), | ||
('last_updated', models.DateTimeField(auto_now=True)), | ||
], | ||
), | ||
] |
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,18 @@ | ||
# -*- coding: utf-8 -*- | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('wagtailpolls', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name='poll', | ||
name='email', | ||
), | ||
] |
Empty file.
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,48 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from six import text_type | ||
|
||
from django.db import models | ||
from django.shortcuts import render | ||
from django.utils.text import slugify | ||
from django.db.models.query import QuerySet | ||
from django.utils import timezone | ||
from wagtail.wagtailadmin.edit_handlers import FieldPanel | ||
from wagtail.wagtailsearch.backends import get_search_backend | ||
|
||
|
||
class PollQuerySet(QuerySet): | ||
def search(self, query_string, fields=None, backend='default'): | ||
""" | ||
This runs a search query on all the pages in the QuerySet | ||
""" | ||
search_backend = get_search_backend(backend) | ||
return search_backend.search(query_string, self) | ||
|
||
|
||
class Poll(models.Model): | ||
issue_date = models.DateTimeField('Issue date', default=timezone.now) | ||
last_updated = models.DateTimeField(auto_now=True) | ||
|
||
panels = [ | ||
FieldPanel('issue_date'), | ||
] | ||
|
||
objects = PollQuerySet.as_manager() | ||
|
||
def get_nice_url(self): | ||
return slugify(text_type(self)) | ||
|
||
def get_template(self, request): | ||
try: | ||
return self.template | ||
except AttributeError: | ||
return '{0}/{1}.html'.format(self._meta.app_label, self._meta.model_name) | ||
|
||
def serve(self, request): | ||
return render(request, self.get_template(request), { | ||
'poll': self, | ||
}) | ||
|
||
# Need to import this down here to prevent circular imports :( | ||
from .views import frontend |
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,15 @@ | ||
from django.conf import settings | ||
from django.core.paginator import Paginator, EmptyPage | ||
|
||
|
||
def paginate(request, items, per_page=settings.DEFAULT_PER_PAGE, | ||
page_key='page'): | ||
paginator = Paginator(items, per_page) | ||
|
||
try: | ||
page_number = int(request.GET[page_key]) | ||
page = paginator.page(page_number) | ||
except (ValueError, KeyError, EmptyPage): | ||
page = paginator.page(1) | ||
|
||
return paginator, page |
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,31 @@ | ||
{% extends "wagtailadmin/base.html" %} | ||
{% load i18n %} | ||
{% block titletag %}{% blocktrans %}New poll{% endblocktrans %}{% endblock %} | ||
{% block bodyclass %}menu-poll{% endblock %} | ||
{% block content %} | ||
{% trans "New" as new_str %} | ||
{% trans "Poll" as pollpost_str %} | ||
{% include "wagtailadmin/shared/header.html" with title=new_str subtitle=pollpost_str icon="group" %} | ||
|
||
<form action="{% url 'wagtailpolls_create' %}" method="POST"> | ||
{% csrf_token %} | ||
{{ edit_handler.render_form_content }} | ||
|
||
<footer> | ||
<ul> | ||
<li class="actions"> | ||
<div class="dropdown dropup dropdown-button match-width"> | ||
<input type="submit" value="{% trans 'Save' %}" name='{{send_button_name}}' /> | ||
</div> | ||
</li> | ||
</ul> | ||
</footer> | ||
</form> | ||
{% endblock %} | ||
|
||
{% block extra_css %} | ||
{% include "wagtailadmin/pages/_editor_css.html" %} | ||
{% endblock %} | ||
{% block extra_js %} | ||
{% include "wagtailadmin/pages/_editor_js.html" %} | ||
{% endblock %} |
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,57 @@ | ||
{% extends "wagtailadmin/base.html" %} | ||
{% load i18n %} | ||
{% block titletag %}{% trans "Polls" %}{% endblock %} | ||
{% block bodyclass %}menu-poll{% endblock %} | ||
|
||
{% block extra_js %} | ||
{% include "wagtailadmin/shared/datetimepicker_translations.html" %} | ||
|
||
<script> | ||
$(function() { | ||
$('#id_date_from').datetimepicker({ | ||
timepicker: false, | ||
format: 'Y-m-d', | ||
i18n: { | ||
lang: window.dateTimePickerTranslations | ||
}, | ||
lang: 'lang' | ||
}); | ||
$('#id_date_to').datetimepicker({ | ||
timepicker: false, | ||
format: 'Y-m-d', | ||
i18n: { | ||
lang: window.dateTimePickerTranslations | ||
}, | ||
lang: 'lang' | ||
}); | ||
}); | ||
</script> | ||
{% endblock %} | ||
|
||
{% block content %} | ||
|
||
<header class="nice-padding" style='padding-bottom:3em;'> | ||
<div class="row row-flush"> | ||
<div class="left col9"> | ||
<div class='col'> | ||
<h1 class="icon icon-edit">{% blocktrans %}Polls{% endblocktrans %} </h1> | ||
</div> | ||
<form class='col search-form' action='{% url 'wagtailpolls_search' %}' method="GET"> | ||
{{search_form}} | ||
<li class="submit visuallyhidden"><input type="submit" value="Search" class="button"></li> | ||
</form> | ||
</div> | ||
|
||
<div class='right col3'> | ||
<div class="addbutton"> | ||
<a href="{% url 'wagtailpolls_create' %}" class="button bicolor icon icon-plus">{% blocktrans %}Add poll{% endblocktrans %}</a> | ||
</div> | ||
</div> | ||
</div> | ||
</header> | ||
{% if poll_list.exists %} | ||
{% include 'wagtailpolls/poll_list.html' %} | ||
{% else %} | ||
<div class="nice-padding">No polls yet!</div> | ||
{% endif %} | ||
{% endblock %} |
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,20 @@ | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from django.conf.urls import url | ||
from .views import chooser, editor | ||
|
||
|
||
urlpatterns = [ | ||
url(r'^$', chooser.index, | ||
name='wagtailpolls_index'), | ||
url(r'^/search/$', chooser.search, | ||
name='wagtailpolls_search'), | ||
url(r'^create/$', editor.create, | ||
name='wagtailpolls_create'), | ||
url(r'^/edit/(?P<poll_pk>.*)/$', editor.edit, | ||
name='wagtailpolls_edit'), | ||
url(r'^/delete/(?P<poll_pk>.*)/$', editor.delete, | ||
name='wagtailpolls_delete'), | ||
url(r'^/copy/(?P<poll_pk>.*)/$', editor.copy, | ||
name='wagtailpolls_copy'), | ||
] |
Oops, something went wrong.