Git Product home page Git Product logo

politikon's Introduction

Politikon - stawiamy na politykę

Join the chat at https://gitter.im/KlubJagiellonski/Politikon Build Status Coverage Status

Politikon Koduj dla Polski Klub Jagielloński

Politikon to serwis internetowy, którego celem jest popularyzowanie pozytywnego spojrzenia na politykę, a także wyłonienia osób, które potrafią przewidywać wydarzenia społeczno-polityczne. Projekt ma pokazać, że polityka to nie tylko cyniczna, losowa gra, ale także miejsce ścierania się idei, pomysłów, miejscem gdzie przyczyny powodują określone skutki. Serwis jest grą internetową, której uczestnicy będą mogli zakładać się o wyniki różnych wydarzeń społeczno-politycznych. Giełdowy charakter gry (rynek przewidywań) pozwala pokazać prawdopodobieństwo wystąpienia określonych wydarzeń, co sprawia, że serwis jest interesującą alternatywą dla sondaży.

Status projektu

Projekt jest w fazie beta-testów od 17 maja 2016. Planowany pełny start projektu to jesień 2016.

Tech docs - in English (dokumentacja techniczna - wyłącznie po angielsku)

PyCharm PE / PyCharm CE IDE configuration

  • PyCharm Professional Edition:

It supports Django out of the box (will propose downloading extension if needed). You should set up environment (local machine with IDE installed).

Environment Variable Development default
DJANGO_SETTINGS_MODULE politikon.settings.dev
POSTGRES_PORT_5432_TCP_PORT 5432
POSTGRES_PORT_5432_TCP_ADDR read below how check it

The last one variable should be set to politikon_db address instance. You could check it using that command (from local machine - NOT VM):

docker inspect --format '{{ .ID }} - {{ .Name }} - {{ .NetworkSettings.IPAddress }}' $(docker ps -q)

Note: in Dockerfile: PORT is hard-coded like here - change if needed; ADDR is not hard-coded because container is configured by Docker to have entry in /etc/hosts (so we use politicon_db there).

  • PyCharm Community Edition:

At this moment there is no ready-to-use config for PyCharm CE. If you done it already - please contribute!

Local instance (for testing) HOW-TO

Mac OS X

Development environment preparation is the same as for GNU/Linux OS familiy using Docker for Mac.

If something not working - please report a bug!

GNU/Linux

Tested on Debian which is fully supported. Pending tests on openSUSE and Mint.

Remember that user who wants to running Docker containers must be permitted to use docker. It is needed for example add that user to docker group.

Also check if docker.service or equivalent daemon runs successfully in your OS.

user@pc$ git clone [email protected]:KlubJagiellonski/Politikon.git
user@pc$ cd Politikon

Tip: better to fork repo, clone that and then set up 'upstream' remote for syncing with base repo. See syncing the fork for more info.

  • Add local.politikon.org.pl as localhost to your OS hosts file (eg. /etc/hosts):
127.0.0.1 local.politikon.org.pl

(required fo Facebook and Twitter sign-in integration)

If you found out some other possibility faster than us - please contribute!

  • Build and run your docker container:
$ docker build -t politikon .
  • Build other necessary containers and start them all:
$ docker-compose up -d
  • Connect to docker:
$ docker-compose exec politikon bash

Parameter force Docker container check (rebuild). It keeps your container up-to-date. Tip: run without any parameter for interactive decision.

When propt appears you are in Docker instance (VM).

root@asdf1234:/app#
  • When on VM you could install dependencies with pip manually:
root@asdf1234:/app# pip install -r requirements.txt

By default running with --build check if they are up-to-date.

  • Default environment variables set up during Docker container build:
export DJANGO_SETTINGS_MODULE="politikon.settings.local"
export POSTGRES_PORT_5432_TCP_PORT="5432"
export POSTGRES_PORT_5432_TCP_ADDR="politikon_db"
  • Now need to do some steps manually... (we will automate that)

  • Connect as 'postgres' user to PostgreSQL instance and create db 'politikon':

root@asdf1234:/app# psql -h ${POSTGRES_PORT_5432_TCP_ADDR} -U postgres
postgres=# CREATE DATABASE politikon WITH ENCODING='UTF8';
  • Migrate the database:
root@asdf1234:/app# python manage.py migrate
  • Configuration should be done. Now run the web server...
root@asdf1234:/app# python manage.py runserver 0.0.0.0:8000
  • ...and check in browser:
http://local.politikon.org.pl:8000

You should see site. Now you know Politikon works on your docker container, but database is empty. Well done :)

Appendix

  • To load example data:
python manage.py loaddata db_dumps/local_test_data.json

You can login for any user - password is an email. For example: username: kowalskijan password: [email protected] Importing that data gives Jan Kowalski the Admin role.

  • If you need to access Django Admin on Docker container:
python manage.py createsuperuser

Then you could access Admin panel in browser:

local.politikon.org.pl:8000/admin
  • If you need to sync your docker local time
boot2docker ssh sudo ntpclient -s -h de.pool.ntp.org
docker run -it -v `pwd`:/app -p 2233:22 -p 8000:8000 --name politikon_instance politikon
  • INFO: regarding to latest bug database is losing consistency during dump. To retrieve consistency do the following:
# go to dbshell
python manage.py dbshell
UPDATE events_bet SET user_id = 1 WHERE user_id NOT IN (SELECT id FROM accounts_userprofile);
UPDATE events_transaction SET user_id = 1 WHERE user_id NOT IN (SELECT id FROM accounts_userprofile);
  • WARNING: destructive code ahead - if you need to rebuild docker containers:
#list running images:
docker ps
# kill running images by providing ids listed from docker ps
docker kill id1 id2
# delete all stopped containers (because running containers will harmlessly error out)
docker rm $(docker ps -a -q)
# delete all images
docker rmi $(docker images -a | awk '{print $3}' | tail -n +2)
# rebuild the whole docker
./docker_rebuild.sh

Autorzy

W projekt są zaangażowani:

  • Klub Jagielloński - treści, prowadzenie gry, marketing, promocja
  • Koduj dla Polski - wsparcie instytucjonalne i osobowe
  • Jacek Głodek
  • Tomek Grynfelder
  • Tomek Kopczuk
  • Kuba Lipiński
  • Marcin Mincer
  • Piotrek Pęczek
  • Michał Nowotnik
  • Wojciech Zając
  • Wojciech Błaszczuk (@julianvolodia)

politikon's People

Contributors

alpaq92 avatar gitter-badger avatar jakublipinski avatar jglodek avatar julianvolodia avatar kamil-7 avatar katarzynaadr avatar mik-laj avatar mnowotnik avatar mstawiarski avatar nausicaaa avatar pawtul avatar ppeczek avatar szufix avatar tgrf avatar vevurka avatar wojtekreu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

politikon's Issues

Newsletter

In user settings should appear an option to receive newsletter and it's frequency. Then users will receive emails with information about their reputation change, event solve notifications, info about their friends actions and many, many more.


Użytkownicy mają możliwość otrzymywania cyklicznych raportów z informacją o zmianie reputacji, nowych wydarzeniach, rozstrzygniętych wydarzeniach, aktywności znajomych i inne

Fix the JSON example data

WIP

Import in container fails.

TODO issue with data json file

django.core.serializers.base.DeserializationError: Problem installing fixture '/app/db_dumps/local_test_data.json': Event has no field named u'is_front'

some errors in webdev console

  • buttons.js

  • stLight

<script type="text/javascript" src="https://ws.sharethis.com/button/buttons.js"></script> <script type="text/javascript">stLight.options({publisher: "8c0ef4da-6251-49e0-ba79-cc5e4d894120", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>

Media share / Politikonowe social media

Users playing should be able to share their decisions on facebook / twitter. It is implemented, but bugged.


Użytkownicy mogą podzielić się ze znajomymi swoim zakładem tagując automatycznie swoich znajomych i konfrontując swoje zdanie z ich zdaniem

New interface, UX enhancements / nowy interfejs, ulepszenia UX

There is an urgent need to redesign Politikon. Our editors are working on it. TODO: cooperate and implement new design in features:

  • Homepage (move footer, make it an event list)
  • Event list
  • Sell a bet

Politikon ma nowy wygląd dla następujących widoków

  • strona główna staje się listą wydarzeń, a stópka jest przeniesiona na górę
  • lista wydarzeń ma lepsze filtrowanie
  • sprzedaż zakładu nie wygląda jak zakup zakładu przeciwnego

Summary of predictions / podsumowanie przewidywań

There is needed new section of resolved events. Each one would show if and when event was predicted (or not) by Politikon. We also need aggregation of informations for each event. Maybe some charts. And design for this view.


Sekcja "Politikon przewidział" wyświetlająca rozstrzygnięte zakłady. Widać w niej czy się udało Politikonowi przewidzieć wynik wydarzenia i z jakim wyprzedzeniem.

Graphs optimization

event.models
Event.__get_chart_points(self, days)
Any graph point cause 1 request to database for 1 element. Too many request to database.

Find and eliminate duplicate request for graph points, request: /events/changed/

Badges for users / odznaki dla graczy

We should label all bets. We can evaluate the prediction skill by checking the time and price of bet creation. Then we can create measures telling whether the user is a speculator, sheep, an oracle or a cover-up. We can even display it to players.


Przypisując odpowiednią etykietę dla każdego zakładu można ocenić umiejętności przewidywania gracza. Następnie są agregowane etykiety i w profilu gracza widać te wskaźniki oraz ostateczną odznakę: spekulant, owieczka, wyrocznia, wiedza tajemna.

Feature - user add event proposal

Story:
1st iterations.

  1. user could add proposal (event with moderate flag - 'not seen' with info about the author (id))
  2. moderator give opinion
  3. new event will be shown

2nd iterations.
4) view with proposals for user
5) history for moderator

3rd iterations.
6) user asks for re-op his proposal

Odzyskiwanie wykresów / Regaining price log

Sometimes redis fails. This stops charts in one point. We need a management command that rebuilds points in "bladespolska" app.

--

Czasami, gdy zapcha się kolejka zadań w redisie, nie są zapamiętywane zmiany w cenach. Potrzeba komendy, która odtworzy te punkty w historii.

Tag navigation / nawigacja tagami

Right now editors are creating tags for events. We want to show them to users and create navigation by tags - tag filtered event list.


W wydarzeniu widać tagi. Po kliknięciu w tag użytkownik jest przenoszony do widoku listy akcji pofiltrowanej po tagu.

Collecting friends of users / Pobieranie znajomych graczy

During registration users friends should be collected, so they can be mentioned in media share, newsletter and be checked if account is real.


Podczas rejestracji znajomi użytkownika powinni zostać pobrani w celu wspomnienia przy dzieleniu się w social media zakładem, w newsletterze oraz sprawdzeniu, czy konto jest prawdziwe.

Chartjs 2.0

For our charts we are currently using js library Chartjs 1.0. We need to upgrade it to 2.0 for the support and new possibilities and redesign.

rejestracja przez google+

próba rejestracji konta przez google+ kończy się statusem: Error 400

reprodukcja:
Na stronie głównej
https://www.politikon.org.pl/pl/
kliknij w graj
a następnie zaloguj przez google

jest : Error 400
powinno być: logowanie powinno zakończyć się sukcesem

Use Python 3.6 and Use Type Hinting

I noticed docstrings in the code that duplicate the "type hinting" feature of Python 3.5 and higher.
Below is an example of how type hinting can produce clean and easy-to-read code:

# current version
def get_object(self, queryset=None):
       """
       Get page for specified language
       :param queryset: current queryset
       :type queryset: QuerySet
       :return: instance of Page
       :rtype: Page
       """ 

# after using type hinting
from django.db.models.query import QuerySet

from .models import Page

def get_object(self, queryset=None: QuerySet) -> Page:
     pass

Using type hinting also allows us to use static code analyzers which will help us produce less buggy code.

Changelog for events / zmiany dla wydarzeń

Each event should display changelog with information about:

  • transactions (buy / sell)

W każdym wydarzeniu powinna być lista akcji dokonanych na wydarzeniu:

  • zakupy zakładów przez użytkowników
  • sprzedaż zakładów przez użytkowników

REST api

Refactor code and implement django rest framework for Politikon mobile app.


Na potrzeby aplikacji mobilnej powstaje API przy pomocy biblioteki django rest framework

fix docker_run.sh and add docker_bye.sh

I fixed docker_run.sh script for:

  • no need to press Return twice to get shell after docker instance up
  • posibility of starting multiple shells

I adding docker_stop.sh for conveninence.

Suggest new event / zaproponuj nowe wydarzenie

New feature leaving possibility to suggest new events by users. After creation they are waiting for moderator approvement. Our editors are working on design.


Użytkownik może zaproponować nowe wydarzenie. Propozycja czeka na zatwierdzenie redaktorów. Widok podobny do suggestera.

New HOWTO for Politikon players / jak grać?

New HOWTO should darken screen and leave highlighted clickable places for users. After click a dialog with description appears. I will try to find screens of described feature and needed library.


Po kliknięciu w "jak grać?" ekran się wyszarza i pojawiają się okrągłe przyciski. Po kliknięciu w przycisk pojawia się okno z informacją o danym elemencie.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.