Skip to content

Commit

Permalink
prepare 0.6.2; make it simple to render list of fobi forms on any page
Browse files Browse the repository at this point in the history
  • Loading branch information
barseghyanartur committed Dec 21, 2015
1 parent d9b09bc commit 91a880c
Show file tree
Hide file tree
Showing 20 changed files with 323 additions and 24 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ are used for versioning (schema follows below):
0.3.4 to 0.4).
- All backwards incompatible changes are mentioned in this document.

0.6.2
-----
2015-12-22

- Make it possible to render a list of forms using custom template tag (not
only on the dashboard page).

0.6.1
-----
2015-12-21
Expand Down
29 changes: 29 additions & 0 deletions examples/requirements_docs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Django
Jinja2
MarkupSafe
MySQL-python
mailchimp
Sphinx
django-admin-tools>=0.5.2
django-autoslug>=1.7.1
django-debug-toolbar>=0.11.0
django-localeurl>=2.0.2
Pillow>=2.0.0
requests>=1.0.0
django-autoslug>=1.3.0
django-nonefield>=0.1
ordereddict>=1.1
six>=1.4.1
easy-thumbnails>=1.4
vishap>=0.1.3,<2.0
Unidecode>=0.04.1
django-nine>=0.1.6
django-registration-redux>=1.1
docutils
ipdb
ipython
ordereddict>=1.1
# Selenium shall always be upgraded
selenium
simple-timer>=0.2
tox
5 changes: 5 additions & 0 deletions examples/simple/foo/templates/foo/forms_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<html>
<body>
{% include theme.forms_list_template %}
</body>
</html>
5 changes: 4 additions & 1 deletion examples/simple/foo/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from django.conf.urls import url

from foo.views import endpoint as foo_views_endpoint
from foo.views import (
endpoint as foo_views_endpoint, forms_list as foo_forms_list,
)

urlpatterns = [
url(r'^endpoint/$', view=foo_views_endpoint, name='foo.endpoint'),
url(r'^forms-list/$', view=foo_forms_list, name='foo.forms_list'),
]
28 changes: 27 additions & 1 deletion examples/simple/foo/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@

from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from django.template import RequestContext
from django.shortcuts import render_to_response

from fobi.models import FormEntry
from fobi.helpers import handle_uploaded_file
from fobi.base import get_theme

logger = logging.getLogger('fobi')

Expand All @@ -22,4 +26,26 @@ def endpoint(request):
for field_name, imf in request.FILES.items():
handle_uploaded_file('foo', "{0}".format(uuid.uuid4()))

return HttpResponse("POST: {0}\nFILES: {1}".format(request.POST, request.FILES))
return HttpResponse(
"POST: {0}\nFILES: {1}".format(request.POST, request.FILES)
)


def forms_list(request, template_name='foo/forms_list.html'):
"""
Fobi forms list.
"""
form_entries = FormEntry._default_manager.filter(is_public=True) \
.select_related('user')
theme = get_theme(request=request, as_instance=True)
context = {
'form_entries': form_entries,
'theme': theme,
'show_custom_actions': False,
'show_edit_link': False,
'show_delete_link': False,
'show_export_link': False,
}
return render_to_response(
template_name, context, context_instance=RequestContext(request)
)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
for locale_dir in locale_dirs:
locale_files += [os.path.join(locale_dir, f) for f in os.listdir(locale_dir)]

version = '0.6.1'
version = '0.6.2'

install_requires = [
'Pillow>=2.0.0',
Expand Down
4 changes: 2 additions & 2 deletions src/fobi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = 'django-fobi'
__version__ = '0.6.1'
__build__ = 0x00004a
__version__ = '0.6.2'
__build__ = 0x00004b
__author__ = 'Artur Barseghyan <artur.barseghyan@gmail.com>'
__copyright__ = '2014-2015 Artur Barseghyan'
__license__ = 'GPL 2.0/LGPL 2.1'
Expand Down
1 change: 1 addition & 0 deletions src/fobi/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class BaseTheme(object):
create_form_entry_template = 'fobi/generic/create_form_entry.html'
create_form_entry_ajax_template = 'fobi/generic/create_form_entry_ajax.html'
dashboard_template = 'fobi/generic/dashboard.html'
forms_list_template = 'fobi/generic/forms_list.html'
edit_form_element_entry_template = \
'fobi/generic/edit_form_element_entry.html'
edit_form_element_entry_ajax_template = \
Expand Down
1 change: 1 addition & 0 deletions src/fobi/contrib/themes/bootstrap3/fobi_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Bootstrap3Theme(BaseTheme):
create_form_entry_ajax_template = 'bootstrap3/create_form_entry_ajax.html'

dashboard_template = 'bootstrap3/dashboard.html'
forms_list_template = 'bootstrap3/forms_list.html'

edit_form_element_entry_template = 'bootstrap3/edit_form_element_entry.html'
edit_form_element_entry_ajax_template = \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "fobi/generic/forms_list.html" %}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ class DjangoCMSAdminStyleTheme(BaseTheme):
create_form_entry_ajax_template = 'djangocms_admin_style_theme/create_form_entry_ajax.html'

dashboard_template = 'djangocms_admin_style_theme/dashboard.html'
forms_list_template = 'djangocms_admin_style_theme/forms_list.html'

edit_form_element_entry_template = 'djangocms_admin_style_theme/edit_form_element_entry.html'
edit_form_element_entry_ajax_template = 'djangocms_admin_style_theme/edit_form_element_entry_ajax.html'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% load i18n %}

<table id="result_list">
<thead>
<tr>
<th>
<div class="text">
<span>{% trans "Name" %}</span>
</div>
<div class="clear"></div>
</th>
{% if show_custom_actions %}
<th>
<div class="text">
<span>{% trans "Actions" %}</span>
</div>
<div class="clear"></div>
</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for form_entry in form_entries %}
<tr class="{% if forloop.counter|divisibleby:2 %}row2{% else %}row1{% endif %}">
<th><a href="{% url 'fobi.view_form_entry' form_entry.slug %}">{{ form_entry.name }}</a></th>
{% if show_custom_actions %}
<td>
<ul class="list-inline">
{% if show_edit_link %}
<li>
<a href="{% url 'fobi.edit_form_entry' form_entry.pk %}" class="edit" title="{% trans 'Edit' %}">
<span></span>
</a>
</li>
{% endif %}
{% if show_delete_link %}
<li>
<a href="{% url 'fobi.delete_form_entry' form_entry.pk %}" class="deletelink" title="{% trans 'Delete' %}">
<span></span>
</a>
</li>
{% endif %}
{% if show_export_link %}
<li>
<a href="{% url 'fobi.export_form_entry' form_entry.pk %}" class="exportlink" title="{% trans 'Export' %}">
<span class="custom-icon custom-icon-export"></span>
</a>
</li>
{% endif %}
</ul>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
1 change: 1 addition & 0 deletions src/fobi/contrib/themes/foundation5/fobi_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class Foundation5Theme(BaseTheme):
create_form_entry_ajax_template = 'foundation5/create_form_entry_ajax.html'

dashboard_template = 'foundation5/dashboard.html'
forms_list_template = 'foundation5/forms_list.html'

edit_form_element_entry_template = 'foundation5/edit_form_element_entry.html'
edit_form_element_entry_ajax_template = \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{% load i18n %}

<table class="table table-striped large-12">
<thead>
<tr>
<th>{% trans "Form" %}</th>
{% if show_custom_actions %}<th>{% trans "Actions" %}</th>{% endif %}
</tr>
</thead>
<tbody>
{% for form_entry in form_entries %}
<tr>
<td><a href="{% url 'fobi.view_form_entry' form_entry.slug %}">{{ form_entry.name }}</a></td>
{% if show_custom_actions %}
<td>
<ul class="inline-list">
{% if show_edit_link %}
<li><a href="{% url 'fobi.edit_form_entry' form_entry.pk %}"><span class="fi-page-edit"></span> {% trans "Edit" %}</a></li>
{% endif %}
{% if show_delete_link %}
<li><a href="{% url 'fobi.delete_form_entry' form_entry.pk %}"><span class="fi-page-delete"></span> {% trans "Delete" %}</a></li>
{% endif %}
{% if show_export_link %}
<li><a href="{% url 'fobi.export_form_entry' form_entry.pk %}"><span class="fi-download"></span> {% trans "Export" %}</a></li>
{% endif %}
</ul>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
1 change: 1 addition & 0 deletions src/fobi/contrib/themes/simple/fobi_themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class SimpleTheme(BaseTheme):
create_form_entry_ajax_template = 'simple/create_form_entry_ajax.html'

dashboard_template = 'simple/dashboard.html'
forms_list_template = 'simple/forms_list.html'

edit_form_element_entry_template = 'simple/edit_form_element_entry.html'
edit_form_element_entry_ajax_template = 'simple/edit_form_element_entry_ajax.html'
Expand Down
56 changes: 56 additions & 0 deletions src/fobi/contrib/themes/simple/templates/simple/forms_list.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% load i18n %}

<table id="result_list">
<thead>
<tr>
<th>
<div class="text">
<span>{% trans "Name" %}</span>
</div>
<div class="clear"></div>
</th>
{% if show_custom_actions %}
<th>
<div class="text">
<span>{% trans "Actions" %}</span>
</div>
<div class="clear"></div>
</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for form_entry in form_entries %}
<tr class="{% if forloop.counter|divisibleby:2 %}row2{% else %}row1{% endif %}">
<th><a href="{% url 'fobi.view_form_entry' form_entry.slug %}">{{ form_entry.name }}</a></th>
{% if show_custom_actions %}
<td>
<ul class="list-inline">
{% if show_edit_link %}
<li>
<a href="{% url 'fobi.edit_form_entry' form_entry.pk %}">
<span class="glyphicon glyphicon-edit"></span> {% trans "Edit" %}
</a>
</li>
{% endif %}
{% if show_delete_link %}
<li>
<a href="{% url 'fobi.delete_form_entry' form_entry.pk %}">
<span class="glyphicon glyphicon-remove"></span> {% trans "Delete" %}
</a>
</li>
{% endif %}
{% if show_export_link %}
<li>
<a href="{% url 'fobi.export_form_entry' form_entry.pk %}">
<span class="glyphicon glyphicon-export"></span> {% trans "Export" %}
</a>
</li>
{% endif %}
</ul>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>

0 comments on commit 91a880c

Please sign in to comment.