-
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
107 changed files
with
6,237 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: gunicorn minent.wsgi --log-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
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,20 @@ | ||
# fugato | ||
# The fugato app is designed to collect questions. | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Thu Oct 23 14:07:41 2014 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
The fugato app is designed to collect questions. | ||
""" | ||
|
||
########################################################################## | ||
## Configuration | ||
########################################################################## | ||
|
||
default_app_config = 'fugato.apps.FugatoConfig' |
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,29 @@ | ||
# fugato.admin | ||
# Description of the app for the admin site and CMS. | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Tue Jul 05 20:04:50 2016 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: admin.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
Description of the app for the admin site and CMS. | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## | ||
|
||
|
||
from django.contrib import admin | ||
from fugato.models import Question, Answer | ||
|
||
########################################################################## | ||
## Register Models | ||
########################################################################## | ||
|
||
admin.site.register(Question) | ||
admin.site.register(Answer) |
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 @@ | ||
# fugato.apps | ||
# Describes the Fugato application for Django | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Wed Mar 04 15:38:51 2015 -0500 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: apps.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
Describes the Fugato application for Django | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## | ||
|
||
from django.apps import AppConfig | ||
|
||
########################################################################## | ||
## Fugato Config | ||
########################################################################## | ||
|
||
class FugatoConfig(AppConfig): | ||
name = 'fugato' | ||
verbose_name = "Fugato" | ||
|
||
def ready(self): | ||
import fugato.signals |
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,29 @@ | ||
# fugato.exceptions | ||
# Custom exceptions for API | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Wed Jan 21 14:59:27 2015 -0500 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: exceptions.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
Custom exceptions for API | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## | ||
|
||
from rest_framework.exceptions import APIException | ||
|
||
########################################################################## | ||
## API Exceptions | ||
########################################################################## | ||
|
||
class DuplicateQuestion(APIException): | ||
|
||
status_code = 400 | ||
default_detail = "question has already been asked" |
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,45 @@ | ||
# fugato.managers | ||
# Custom managers for the fugato models | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Wed Jul 22 14:03:52 2015 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: managers.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
Custom managers for the fugato models | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## | ||
|
||
from django.db import models | ||
from minent.utils import signature | ||
|
||
########################################################################## | ||
## Questions Manager | ||
########################################################################## | ||
|
||
class QuestionManager(models.Manager): | ||
|
||
def dedupe(self, raise_for_exceptions=False, **kwargs): | ||
""" | ||
Essentially a GET or CREATE method that checks if a duplicate | ||
question already exists in the database by its signature. If | ||
raise_for_exceptions is True, then will raise a DuplicateQuestion | ||
exception, otherwise it will return None. | ||
Returns question, created where created is a Boolean | ||
""" | ||
qsig = signature(kwargs['text']) | ||
query = self.filter(signature=qsig) | ||
if query.exists(): | ||
if raise_for_exceptions: | ||
raise DuplicateQuestion() | ||
return query.first(), False | ||
|
||
return self.create(**kwargs), 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,66 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.7 on 2016-07-06 00:28 | ||
from __future__ import unicode_literals | ||
|
||
import autoslug.fields | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import django.utils.timezone | ||
import model_utils.fields | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Answer', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||
('text', models.TextField(help_text='Edit in Markdown')), | ||
('text_rendered', models.TextField(editable=False)), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'get_latest_by': 'created', | ||
'db_table': 'answers', | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Question', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created', model_utils.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False, verbose_name='created')), | ||
('modified', model_utils.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False, verbose_name='modified')), | ||
('text', models.CharField(max_length=512)), | ||
('slug', autoslug.fields.AutoSlugField(editable=False, populate_from='text', unique=True)), | ||
('signature', models.CharField(editable=False, max_length=28, unique=True)), | ||
('details', models.TextField(blank=True, default=None, help_text='Edit in Markdown', null=True)), | ||
('details_rendered', models.TextField(blank=True, default=None, editable=False, null=True)), | ||
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='questions', to=settings.AUTH_USER_MODEL)), | ||
('related', models.ManyToManyField(related_name='_question_related_+', to='fugato.Question')), | ||
], | ||
options={ | ||
'get_latest_by': 'created', | ||
'db_table': 'questions', | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='answer', | ||
name='question', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='answers', to='fugato.Question'), | ||
), | ||
migrations.AddField( | ||
model_name='answer', | ||
name='related', | ||
field=models.ManyToManyField(related_name='_answer_related_+', to='fugato.Answer'), | ||
), | ||
] |
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.migrations | ||
# Database migrations for the fugato application | ||
# | ||
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com> | ||
# Created: Tue Jul 05 20:03:22 2016 -0400 | ||
# | ||
# Copyright (C) 2016 District Data Labs | ||
# For license information, see LICENSE.txt | ||
# | ||
# ID: __init__.py [] benjamin@bengfort.com $ | ||
|
||
""" | ||
Database migrations for the fugato application | ||
""" | ||
|
||
########################################################################## | ||
## Imports | ||
########################################################################## |
Oops, something went wrong.