-
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
82 changed files
with
391 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] [email protected] $ | ||
# ID: __init__.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
The fugato app is designed to collect questions. | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: admin.py [] [email protected] $ | ||
# ID: admin.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Description of the app for the admin site and CMS. | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: apps.py [] [email protected] $ | ||
# ID: apps.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Describes the Fugato application for Django | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: exceptions.py [] [email protected] $ | ||
# ID: exceptions.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Custom exceptions for API | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: managers.py [] [email protected] $ | ||
# ID: managers.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Custom managers for the fugato models | ||
|
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,22 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.7 on 2016-07-10 13:09 | ||
from __future__ import unicode_literals | ||
|
||
import autoslug.fields | ||
from django.db import migrations | ||
from slugify import slugify | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('fugato', '0003_auto_20160707_2054'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='question', | ||
name='slug', | ||
field=autoslug.fields.AutoSlugField(editable=False, populate_from='text', slugify=slugify, unique=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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] [email protected] $ | ||
# ID: __init__.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Database migrations for the fugato application | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: models.py [] [email protected] $ | ||
# ID: models.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Models for the fugato app. | ||
|
@@ -27,7 +27,7 @@ | |
from model_utils.models import TimeStampedModel | ||
from django.core.urlresolvers import reverse | ||
from django.contrib.contenttypes.fields import GenericRelation | ||
|
||
from slugify import slugify | ||
from operator import itemgetter | ||
|
||
########################################################################## | ||
|
@@ -36,15 +36,15 @@ | |
|
||
class Question(TimeStampedModel): | ||
|
||
text = models.CharField( max_length=512, null=False ) # The text of the question | ||
slug = AutoSlugField( populate_from='text', unique=True ) # The slug of the question | ||
text = models.CharField( max_length=512, null=False ) # The text of the question | ||
slug = AutoSlugField( populate_from='text', slugify=slugify, unique=True ) # The slug of the question | ||
signature = models.CharField( max_length=28, unique=True, editable=False ) # The normalized signature | ||
details = models.TextField( help_text="Edit in Markdown", **nullable ) # Additional details about the question | ||
details_rendered = models.TextField( editable=False, **nullable ) # HTML rendered details text from MD | ||
related = models.ManyToManyField( 'self', editable=True, blank=True ) # Links between related questions | ||
author = models.ForeignKey( 'auth.User', related_name='questions' ) # The author of the question | ||
votes = GenericRelation( Vote, related_query_name='questions' ) # Vote on whether or not the question is relevant | ||
tags = models.ManyToManyField('tagging.Tag', related_name='questions') # Tag each question with terms for easy lookup | ||
details = models.TextField( help_text="Edit in Markdown", **nullable ) # Additional details about the question | ||
details_rendered = models.TextField( editable=False, **nullable ) # HTML rendered details text from MD | ||
related = models.ManyToManyField( 'self', editable=True, blank=True ) # Links between related questions | ||
author = models.ForeignKey( 'auth.User', related_name='questions' ) # The author of the question | ||
votes = GenericRelation( Vote, related_query_name='questions' ) # Vote on whether or not the question is relevant | ||
tags = models.ManyToManyField('tagging.Tag', related_name='questions') # Tag each question with terms for easy lookup | ||
|
||
## Set custom manager on Question | ||
objects = QuestionManager() | ||
|
@@ -61,6 +61,12 @@ def get_api_detail_url(self): | |
""" | ||
return reverse('api:question-detail', args=(self.pk,)) | ||
|
||
def get_stream_repr(self): | ||
""" | ||
Returns the object representation for the activity stream. | ||
""" | ||
return '“{}”'.format(self) | ||
|
||
def has_tag(self, tag): | ||
""" | ||
Returns True if the tag (a string) is in the list of tags. | ||
|
@@ -107,11 +113,26 @@ class Meta: | |
db_table = "answers" | ||
order_with_respect_to = 'question' | ||
|
||
def get_absolute_url(self): | ||
""" | ||
Return the detail view of the Answer object, that is the url of the | ||
question with the vertical reference to the answer attached. | ||
""" | ||
url = self.question.get_absolute_url() | ||
url += "#answer-{}".format(self.id) | ||
return url | ||
|
||
def get_api_detail_url(self): | ||
""" | ||
Returns the API detail endpoint for the object | ||
""" | ||
return reverse('api:answer-detail', args=(self.pk,)) | ||
|
||
def get_stream_repr(self): | ||
""" | ||
Returns the object representation for the activity stream. | ||
""" | ||
return self.question.get_stream_repr() | ||
|
||
def __str__(self): | ||
return self.text |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: serializers.py [] [email protected] $ | ||
# ID: serializers.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
JSON Serializers for the Fugato app | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: signals.py [] [email protected] $ | ||
# ID: signals.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Signals for the fugato app | ||
|
@@ -80,8 +80,7 @@ def send_answered_activity_signal(sender, instance, created, **kwargs): | |
'sender': sender, | ||
'actor': instance.author, | ||
'verb': 'answer', | ||
'theme': instance, | ||
'target': instance.question, | ||
'target': instance, | ||
'timestamp': instance.created, | ||
} | ||
stream.send(**activity) |
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] [email protected] $ | ||
# ID: __init__.py [6f1c3bb] [email protected] $ | ||
|
||
""" | ||
Template tags for fugato (though also generic usage as well). | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: paginator.py [] [email protected] $ | ||
# ID: paginator.py [6f1c3bb] [email protected] $ | ||
|
||
""" | ||
Provides a paginator tag context for digg-style pagination. | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: tests.py [] [email protected] $ | ||
# ID: tests.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Tests the fugato app | ||
|
@@ -119,26 +119,22 @@ def test_question_answer_send_stream(self): | |
|
||
# Ensure that the signal was sent once with required arguments | ||
handler.assert_called_once_with(verb='answer', sender=Answer, | ||
timestamp=answer.created, actor=self.user, theme=answer, | ||
target=self.question, signal=stream) | ||
timestamp=answer.created, actor=self.user, target=answer, | ||
signal=stream) | ||
|
||
def test_question_answered_activity(self): | ||
""" | ||
Assert that when a question is answered, there is an activity stream item | ||
""" | ||
answer = Answer.objects.create(**fixtures['answer']) | ||
target_content_type = ContentType.objects.get_for_model(answer.question) | ||
target_object_id = answer.question.id | ||
theme_content_type = ContentType.objects.get_for_model(answer) | ||
theme_object_id = answer.id | ||
target_content_type = ContentType.objects.get_for_model(answer) | ||
target_object_id = answer.id | ||
|
||
query = { | ||
'verb': 'answer', | ||
'actor': self.user, | ||
'target_content_type': target_content_type, | ||
'target_object_id': target_object_id, | ||
'theme_content_type': theme_content_type, | ||
'theme_object_id': theme_object_id, | ||
} | ||
|
||
query = StreamItem.objects.filter(**query) | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: views.py [] [email protected] $ | ||
# ID: views.py [8eae6c4] [email protected] $ | ||
|
||
""" | ||
Views for the Fugato app | ||
|
@@ -185,8 +185,8 @@ def tags(self, request, pk=None): | |
if question.has_tag(tag): continue | ||
|
||
# Otherwise, get or create the tag | ||
tag, _ = Tag.objects.get_or_create( | ||
text = tag, | ||
tag, _ = Tag.objects.tag( | ||
tag, | ||
defaults = { | ||
'creator': request.user, | ||
} | ||
|
@@ -196,8 +196,11 @@ def tags(self, request, pk=None): | |
question.tags.add(tag) | ||
|
||
# Next delete any tags that were removed from the question | ||
slugs = [ | ||
slugify(t) for t in serializer.validated_data['csv_tags'] | ||
] | ||
for tag in question.tags.all(): | ||
if tag.text not in serializer.validated_data['csv_tags']: | ||
if tag.slug not in slugs: | ||
question.tags.remove(tag) | ||
|
||
return Response(CSVTagSerializer.serialize_question(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 |
---|---|---|
|
@@ -8,7 +8,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: manage.py [] [email protected] $ | ||
# ID: manage.py [916a654] [email protected] $ | ||
|
||
""" | ||
Django default management commands, with some special sauce. | ||
|
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 |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] [email protected] $ | ||
# ID: __init__.py [916a654] [email protected] $ | ||
|
||
""" | ||
The Minimum Entropy project definition module. | ||
|
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 |
---|---|---|
@@ -1,20 +1,35 @@ | ||
/* Styles for the tag grid page */ | ||
|
||
.tag-block { | ||
min-height: 128px; | ||
height: 192px; | ||
position: relative; | ||
border-bottom: 1px solid #ccc; | ||
margin: 8px 0; | ||
} | ||
|
||
.tag-question-count { | ||
border: 1px solid #ccc; | ||
width: 64px; | ||
height: 64px; | ||
padding-top: 6px; | ||
.tag-heading-left { | ||
width: 80%; | ||
} | ||
|
||
.tag-name { | ||
font-size: 0.90em; | ||
} | ||
|
||
.tag-count { | ||
padding-left: 6px; | ||
} | ||
|
||
.tag-body { | ||
margin: 6px 0; | ||
} | ||
|
||
|
||
.tag-description { | ||
font-size: .9em; | ||
font-size: .85em; | ||
} | ||
|
||
.tag-meta-list { | ||
font-size: .8em; | ||
position: absolute; | ||
bottom: 0; | ||
} |
Oops, something went wrong.