-
Notifications
You must be signed in to change notification settings - Fork 3
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
Showing
50 changed files
with
1,686 additions
and
283 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
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,26 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.7 on 2016-07-07 21:05 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('tagging', '0001_initial'), | ||
('fugato', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='question', | ||
name='tags', | ||
field=models.ManyToManyField(related_name='questions', to='tagging.Tag'), | ||
), | ||
migrations.AlterField( | ||
model_name='question', | ||
name='related', | ||
field=models.ManyToManyField(blank=True, related_name='_question_related_+', to='fugato.Question'), | ||
), | ||
] |
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 -*- | ||
# Generated by Django 1.9.7 on 2016-07-08 00:54 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('fugato', '0002_auto_20160707_1705'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterModelOptions( | ||
name='answer', | ||
options={}, | ||
), | ||
migrations.AlterOrderWithRespectTo( | ||
name='answer', | ||
order_with_respect_to='question', | ||
), | ||
] |
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,18 @@ | ||
# fugato.templatetags | ||
# Template tags for fugato (though also generic usage as well). | ||
# | ||
# Author: Benjamin Bengfort <[email protected]> | ||
# Created: Fri Jul 08 12:37:23 2016 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] [email protected] $ | ||
|
||
""" | ||
Template tags for fugato (though also generic usage as well). | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## |
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,75 @@ | ||
# fugato.templatetags.paginator | ||
# Provides a paginator tag context for digg-style pagination. | ||
# | ||
# Author: Benjamin Bengfort <[email protected]> | ||
# Created: Fri Jul 08 12:38:38 2016 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: paginator.py [] [email protected] $ | ||
|
||
""" | ||
Provides a paginator tag context for digg-style pagination. | ||
Based on: http://www.djangosnippets.org/snippets/73/ | ||
Modified by Sean Reifschneider to be smarter about surrounding page | ||
link context. For usage documentation see: | ||
http://www.tummy.com/Community/Articles/django-pagination/ | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## | ||
|
||
from django import template | ||
|
||
########################################################################## | ||
## Module Constants | ||
########################################################################## | ||
|
||
register = template.Library() | ||
|
||
|
||
########################################################################## | ||
## Inclusion Tags | ||
########################################################################## | ||
|
||
@register.inclusion_tag('components/pagination.html', takes_context=True) | ||
def paginator(context, adjacent_pages=2): | ||
""" | ||
To be used in conjunction with the object_list generic view. | ||
Adds pagination context variables for use in displaying first, adjacent and | ||
last page links in addition to those created by the object_list generic | ||
view. | ||
""" | ||
|
||
# Collect the pagination objects from the context | ||
page_obj = context['page_obj'] | ||
paginator = context['paginator'] | ||
|
||
# Determine the start page for the paginator | ||
startPage = max(page_obj.number - adjacent_pages, 1) | ||
if startPage <= 3: startPage = 1 | ||
|
||
# Determine the end page for the paginatio | ||
endPage = page_obj.number + adjacent_pages + 1 | ||
if endPage >= paginator.num_pages - 1: endPage = paginator.num_pages + 1 | ||
|
||
# Create a list of page numbers to iterate over on the front end. | ||
page_numbers = [ | ||
idx for idx in range(startPage, endPage) | ||
if idx > 0 and idx <= paginator.num_pages | ||
] | ||
|
||
# Return a new context with the computed pagination ranges. | ||
return { | ||
'page_obj': page_obj, | ||
'paginator': paginator, | ||
'page_numbers': page_numbers, | ||
'show_first': 1 not in page_numbers, | ||
'show_last': paginator.num_pages not in page_numbers, | ||
} |
Oops, something went wrong.