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
58 changed files
with
1,234 additions
and
90 deletions.
There are no files selected for viewing
1 change: 0 additions & 1 deletion
1
...os/molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale
Submodule molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale
deleted from
f6c9af
1 change: 0 additions & 1 deletion
1
...content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_more_than_10
Submodule molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_more_than_10
deleted from
5f4fd5
1 change: 0 additions & 1 deletion
1
...re.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_multirepo
Submodule molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_multirepo
deleted from
5f4fd5
1 change: 0 additions & 1 deletion
1
...ent_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_multirepo_strays
Submodule molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_get_locale_multirepo_strays
deleted from
87717c
1 change: 0 additions & 1 deletion
1
...olo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_unknown_locale
Submodule molo.core.content_import.tests.test_api_get_languages.TestGetLanguages.test_unknown_locale
deleted from
1a8faa
1 change: 0 additions & 1 deletion
1
...olo.core.content_import.tests.test_api_import_content.TestImportContent.test_image_import
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_image_import
deleted from
7999e1
1 change: 0 additions & 1 deletion
1
...core.content_import.tests.test_api_import_content.TestImportContent.test_import_multirepo
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_multirepo
deleted from
7999e1
1 change: 0 additions & 1 deletion
1
...t_import.tests.test_api_import_content.TestImportContent.test_import_multirepo_idempotent
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_multirepo_idempotent
deleted from
9e30c5
1 change: 0 additions & 1 deletion
1
...tests.test_api_import_content.TestImportContent.test_import_multirepo_no_primary_category
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_multirepo_no_primary_category
deleted from
3db000
1 change: 0 additions & 1 deletion
1
...nt_import.tests.test_api_import_content.TestImportContent.test_import_no_primary_category
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_no_primary_category
deleted from
3db000
1 change: 0 additions & 1 deletion
1
...molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_page
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_page
deleted from
4c2b2e
1 change: 0 additions & 1 deletion
1
...tests.test_api_import_content.TestImportContent.test_import_sections_for_primary_language
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_import_sections_for_primary_language
deleted from
2a1dd9
1 change: 0 additions & 1 deletion
1
...ntent_import.tests.test_api_import_content.TestImportContent.test_multiple_main_languages
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_multiple_main_languages
deleted from
2e61ab
1 change: 0 additions & 1 deletion
1
...core.content_import.tests.test_api_import_content.TestImportContent.test_no_main_language
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_no_main_language
deleted from
f0d768
1 change: 0 additions & 1 deletion
1
...o.core.content_import.tests.test_api_import_content.TestImportContent.test_strays_omitted
Submodule molo.core.content_import.tests.test_api_import_content.TestImportContent.test_strays_omitted
deleted from
522060
1 change: 0 additions & 1 deletion
1
...content_import.tests.test_api_validate_content.TestValidateContent.test_import_validation
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_import_validation
deleted from
157bdb
1 change: 0 additions & 1 deletion
1
...port.tests.test_api_validate_content.TestValidateContent.test_import_validation_multirepo
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_import_validation_multirepo
deleted from
e96c8d
1 change: 0 additions & 1 deletion
1
...t_import.tests.test_api_validate_content.TestValidateContent.test_multiple_main_languages
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_multiple_main_languages
deleted from
ad4142
1 change: 0 additions & 1 deletion
1
....content_import.tests.test_api_validate_content.TestValidateContent.test_no_main_language
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_no_main_language
deleted from
ad4142
1 change: 0 additions & 1 deletion
1
.../molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_strays
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_strays
deleted from
4ec386
1 change: 0 additions & 1 deletion
1
...port.tests.test_api_validate_content.TestValidateContent.test_wagtail_language_validation
Submodule molo.core.content_import.tests.test_api_validate_content.TestValidateContent.test_wagtail_language_validation
deleted from
ede09c
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 |
---|---|---|
@@ -1 +1 @@ | ||
5.3.1 | ||
5.4.2 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,73 @@ | ||
from django.contrib import admin | ||
from django.core.urlresolvers import reverse | ||
from molo.core.models import ( | ||
ReactionQuestion, ReactionQuestionResponse, ArticlePage) | ||
from wagtail.contrib.modeladmin.options import ModelAdmin as WagtailModelAdmin | ||
|
||
|
||
class ReactionQuestionAdmin(admin.ModelAdmin): | ||
list_display = ('title', 'live') | ||
fieldsets = ( | ||
( | ||
None, | ||
{'fields': ('title', )} | ||
), | ||
) | ||
readonly_fields = ['title'] | ||
|
||
|
||
class ReactionQuestionResponseAdmin(admin.ModelAdmin): | ||
list_display = ('question', 'choice', 'user', 'article') | ||
fieldsets = ( | ||
( | ||
None, | ||
{'fields': ('question', 'choice', 'user', 'article')} | ||
), | ||
) | ||
readonly_fields = ['question', 'choice'] | ||
|
||
admin.site.register(ReactionQuestion, ReactionQuestionAdmin) | ||
admin.site.register(ReactionQuestionResponse, ReactionQuestionResponseAdmin) | ||
|
||
|
||
class ReactionQuestionsModelAdmin(WagtailModelAdmin, ReactionQuestionAdmin): | ||
model = ReactionQuestion | ||
menu_label = 'Reaction Question' | ||
menu_icon = 'doc-full' | ||
add_to_settings_menu = False | ||
list_display = ('responses', 'live') | ||
|
||
def responses(self, obj, *args, **kwargs): | ||
url = reverse('reaction-question-results-admin', args=(obj.id,)) | ||
return '<a href="%s">%s</a>' % (url, obj) | ||
|
||
def get_queryset(self, request): | ||
qs = super(ReactionQuestionAdmin, self).get_queryset(request) | ||
# Only show questions related to that site | ||
main = request.site.root_page | ||
return qs.descendant_of(main) | ||
|
||
responses.allow_tags = True | ||
responses.short_description = 'Title' | ||
|
||
|
||
class ReactionQuestionsSummaryModelAdmin( | ||
WagtailModelAdmin, ReactionQuestionAdmin): | ||
model = ArticlePage | ||
menu_label = 'Reaction Question Summary' | ||
menu_icon = 'doc-full' | ||
add_to_settings_menu = False | ||
list_display = ('articles', 'live') | ||
|
||
def articles(self, obj, *args, **kwargs): | ||
url = reverse( | ||
'reaction-question-article-results-admin', args=(obj.id,)) | ||
return '<a href="%s">%s</a>' % (url, obj) | ||
|
||
def get_queryset(self, request): | ||
qs = ArticlePage.objects.descendant_of( | ||
request.site.root_page).exclude(reaction_questions=None) | ||
return qs | ||
|
||
articles.allow_tags = True | ||
articles.short_description = 'Title' |
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,102 @@ | ||
import csv | ||
from collections import OrderedDict | ||
from django.http.response import HttpResponse | ||
from django.shortcuts import get_object_or_404, render | ||
from django.views.generic.edit import FormView | ||
from molo.core.models import ReactionQuestionResponse, ReactionQuestion, \ | ||
ArticlePageReactionQuestions, ArticlePage | ||
|
||
|
||
class ReactionQuestionSummaryAdminView(FormView): | ||
def get(self, request, *args, **kwargs): | ||
article = kwargs['article'] | ||
article = get_object_or_404(ArticlePage, pk=article) | ||
question = ArticlePageReactionQuestions.objects.get( | ||
page=article).reaction_question | ||
data_headings = ['Article'] | ||
data_rows = [] | ||
choices = question.get_children().filter( | ||
languages__language__is_main_language=True) | ||
choice_totals = [] | ||
for choice in choices: | ||
data_headings.append(choice.title) | ||
responses = ReactionQuestionResponse.objects.filter( | ||
question=question, article=article, choice=choice) | ||
choice_totals.append(responses.count()) | ||
row = OrderedDict({}) | ||
article = article.title | ||
row['article'] = article | ||
counter = 0 | ||
for i in choice_totals: | ||
row[counter] = i | ||
counter += 1 | ||
data_rows.append(row) | ||
action = request.GET.get('action', None) | ||
if action == 'download': | ||
return self.send_csv(question.title, data_headings, data_rows) | ||
|
||
context = { | ||
'page_title': question.title, | ||
'data_headings': data_headings, | ||
'data_rows': data_rows | ||
} | ||
|
||
return render(request, 'admin/question_results.html', context) | ||
|
||
def send_csv(self, question_title, data_headings, data_rows): | ||
response = HttpResponse(content_type='text/csv') | ||
response['Content-Disposition'] = \ | ||
'attachment;filename="reaction-question-{0}-results.csv"'.format( | ||
question_title) | ||
|
||
writer = csv.writer(response) | ||
writer.writerow(data_headings) | ||
|
||
for item in data_rows: | ||
writer.writerow(item.values()) | ||
|
||
return response | ||
|
||
|
||
class ReactionQuestionResultsAdminView(FormView): | ||
def get(self, request, *args, **kwargs): | ||
parent = kwargs['parent'] | ||
question = get_object_or_404(ReactionQuestion, pk=parent) | ||
|
||
data_headings = ['Submission Date', 'Answer', 'User', 'Article'] | ||
data_rows = [] | ||
|
||
for response in ReactionQuestionResponse.objects.filter( | ||
question=question): | ||
data_rows.append(OrderedDict({ | ||
'submission_date': response.created_at, | ||
'answer': response.choice, | ||
'user': response.user, | ||
'article': response.article | ||
})) | ||
|
||
action = request.GET.get('action', None) | ||
if action == 'download': | ||
return self.send_csv(question.title, data_headings, data_rows) | ||
|
||
context = { | ||
'page_title': question.title, | ||
'data_headings': ['Submission Date', 'Answer', 'User', 'Article'], | ||
'data_rows': data_rows | ||
} | ||
|
||
return render(request, 'admin/question_results.html', context) | ||
|
||
def send_csv(self, question_title, data_headings, data_rows): | ||
response = HttpResponse(content_type='text/csv') | ||
response['Content-Disposition'] = \ | ||
'attachment;filename="reaction-question-{0}-results.csv"'.format( | ||
question_title) | ||
|
||
writer = csv.writer(response) | ||
writer.writerow(data_headings) | ||
|
||
for item in data_rows: | ||
writer.writerow(item.values()) | ||
|
||
return response |
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,81 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9.13 on 2017-05-24 11:55 | ||
from __future__ import unicode_literals | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import modelcluster.fields | ||
import molo.core.models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('wagtailcore', '0032_add_bulk_delete_page_permission'), | ||
('wagtailimages', '0018_remove_rendition_filter'), | ||
('core', '0058_section_tags'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ArticlePageReactionQuestions', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('sort_order', models.IntegerField(blank=True, editable=False, null=True)), | ||
('page', modelcluster.fields.ParentalKey(on_delete=django.db.models.deletion.CASCADE, related_name='reaction_questions', to='core.ArticlePage')), | ||
], | ||
options={ | ||
'ordering': ['sort_order'], | ||
'abstract': False, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='ReactionQuestion', | ||
fields=[ | ||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(molo.core.models.TranslatablePageMixin, 'wagtailcore.page'), | ||
), | ||
migrations.CreateModel( | ||
name='ReactionQuestionChoice', | ||
fields=[ | ||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), | ||
('image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=(molo.core.models.TranslatablePageMixinNotRoutable, 'wagtailcore.page'), | ||
), | ||
migrations.CreateModel( | ||
name='ReactionQuestionIndexPage', | ||
fields=[ | ||
('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), | ||
], | ||
options={ | ||
'abstract': False, | ||
}, | ||
bases=('wagtailcore.page', molo.core.models.PreventDeleteMixin), | ||
), | ||
migrations.CreateModel( | ||
name='ReactionQuestionResponse', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('created_at', models.DateTimeField(auto_now_add=True)), | ||
('article', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.ArticlePage')), | ||
('choice', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='core.ReactionQuestionChoice')), | ||
('question', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='core.ReactionQuestion')), | ||
('user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
migrations.AddField( | ||
model_name='articlepagereactionquestions', | ||
name='reaction_question', | ||
field=models.ForeignKey(blank=True, help_text='Reaction Questions', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page'), | ||
), | ||
] |
Oops, something went wrong.