-
Notifications
You must be signed in to change notification settings - Fork 5
Democracy hackathon #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jonas-braun
wants to merge
7
commits into
wepublic:master
Choose a base branch
from
jonas-braun:democracy-hackathon
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e7f3e38
local settings
jonas-braun eb07b92
wp_match app basics
jonas-braun 23fb53d
create_users script: add parties to answers
jonas-braun ad9eb5c
fix user to admin@wepublic.me
jonas-braun 08237cc
add percentage calulation to views
diazcelsa 83e8c25
parties percentage response to nice list of dicts
diazcelsa be7a949
reponse object
jonas-braun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,4 +7,3 @@ htmlcov/ | |
| wepublic_backend/staticfiles/ | ||
| media/ | ||
| activate | ||
| settings_local.py | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -48,6 +48,7 @@ | |
| 'wp_news', | ||
| 'wp_newsletter', | ||
| 'wp_party', | ||
| 'wp_match', | ||
| ] | ||
|
|
||
| MIDDLEWARE = [ | ||
|
|
||
This file contains hidden or 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,35 @@ | ||
| import os | ||
|
|
||
|
|
||
| SECRET_KEY = 'secretsecretsecret' | ||
|
|
||
| # SECURITY WARNING: don't run with debug turned on in production! | ||
| DEBUG = True | ||
|
|
||
| ALLOWED_HOSTS = ['*'] | ||
|
|
||
| PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | ||
| DATABASES = { | ||
| 'default': { | ||
| 'ENGINE': 'django.db.backends.sqlite3', | ||
| 'NAME': os.path.join(PROJECT_ROOT, 'database.sqlite') | ||
| } | ||
| } | ||
|
|
||
| MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media') | ||
| MEDIA_URL = '/media/' | ||
|
|
||
| STATIC_ROOT = os.path.join(PROJECT_ROOT, 'staticfiles') | ||
| STATIC_URL = '/static/' | ||
|
|
||
| EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" | ||
| EMAIL_FILE_PATH = '/tmp/mails' | ||
| EMAIL_HOST = '' | ||
| EMAIL_PORT = '' | ||
| EMAIL_HOST_USER = '' | ||
| EMAIL_HOST_PASSWORD = '' | ||
| REPORT_MAILS = [] | ||
| REPORT_MAILS_ACTIVE = True | ||
|
|
||
| SLACK_NOTIFICATIONS_ACTIVE = False | ||
| SLACK_NOTIFICATIONS_URL = '' |
This file contains hidden or 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
Empty file.
This file contains hidden or 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,3 @@ | ||
| from django.contrib import admin | ||
|
|
||
| # Register your models here. |
This file contains hidden or 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,5 @@ | ||
| from django.apps import AppConfig | ||
|
|
||
|
|
||
| class WpMatchConfig(AppConfig): | ||
| name = 'wp_match' |
Empty file.
This file contains hidden or 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,3 @@ | ||
| from django.db import models | ||
|
|
||
| # Create your models here. |
This file contains hidden or 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,3 @@ | ||
| from django.test import TestCase | ||
|
|
||
| # Create your tests here. |
This file contains hidden or 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,9 @@ | ||
|
|
||
| from django.conf.urls import url | ||
|
|
||
| from . import views | ||
|
|
||
| urlpatterns = [ | ||
| url(r'^$', views.index, name="index") | ||
|
|
||
| ] |
This file contains hidden or 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,35 @@ | ||
| from rest_framework import viewsets | ||
| from rest_framework.permissions import IsAuthenticated | ||
| from rest_framework.decorators import detail_route | ||
| from wp_core.models import Answer | ||
| from collections import Counter | ||
|
|
||
| from django.http import JsonResponse | ||
|
|
||
| from users.models import User | ||
| import json | ||
|
|
||
|
|
||
| @detail_route(methods=['get'], permission_classes=[IsAuthenticated]) | ||
| def index(request): | ||
| user = User.objects.get(email='admin@wepublic.me') | ||
|
|
||
| # get the amount of positive voted answers per user | ||
| answers = Answer.objects.filter(voteanswer__user=user, voteanswer__up=True) | ||
| c = Counter() | ||
| c.update([a.party for a in answers]) | ||
| keys = [k.short_name for k in list(c.keys())] | ||
| a = dict(zip(keys, c.values())) | ||
| total = [(k, (v / sum(a.values())) * 100) for k, v in a.items()] | ||
| parties = [x[0] for x in total] | ||
| percentage = [x[1] for x in total] | ||
|
|
||
| response = [] | ||
| for i, party in enumerate(total): | ||
| d_party = { | ||
| 'name': parties[i], | ||
| 'percentage': percentage[i] | ||
| } | ||
| response.append(d_party) | ||
|
|
||
| return JsonResponse(response, safe=False) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have database entries for those.