This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
forked from ofri/Open-Knesset
-
Notifications
You must be signed in to change notification settings - Fork 174
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #662 from alonisser/bugfix_635_629
Bugfix 635 629 Bill statistics calculation and bill queryset display fixing logic
- Loading branch information
Showing
38 changed files
with
1,852 additions
and
1,600 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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,3 +1,4 @@ | ||
# encoding: utf-8 | ||
''' | ||
API for the laws 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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
# encoding: utf-8 | ||
import datetime | ||
|
||
STANDS_FOR_THRESHOLD = 0.66 | ||
FIRST_KNESSET_START = datetime.date(1948, 5, 13) | ||
CONVERT_TO_DISCUSSION_HEADERS = ('להעביר את הנושא'.decode('utf8'), 'העברת הנושא'.decode('utf8')) |
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 |
---|---|---|
@@ -1,59 +1,87 @@ | ||
#encoding: utf-8 | ||
# encoding: utf-8 | ||
from django.db.models.signals import m2m_changed, post_save | ||
from django.contrib.contenttypes.models import ContentType | ||
from actstream import action | ||
from actstream.models import Action | ||
from tagging.models import TaggedItem | ||
|
||
from knesset.utils import cannonize, disable_for_loaddata | ||
from laws.models.bill import Bill | ||
from laws.models.candidate_list_model_statistics import CandidateListVotingStatistics | ||
from laws.models.member_voting_statistics import MemberVotingStatistics | ||
from laws.models.party_voting_statistics import PartyVotingStatistics | ||
from laws.models.proposal import PrivateProposal | ||
from laws.models.vote_action import VoteAction | ||
from mks.models import Member, Party | ||
from laws.models import PrivateProposal, VoteAction, MemberVotingStatistics,\ | ||
PartyVotingStatistics, CandidateListVotingStatistics | ||
|
||
from polyorg.models import CandidateList | ||
from ok_tag.models import add_tags_to_related_objects | ||
|
||
def record_bill_proposal(**kwargs): | ||
if kwargs['action'] != "post_add": | ||
return | ||
private_proposal_ct = ContentType.objects.get(app_label="laws", model="privateproposal") | ||
member_ct = ContentType.objects.get(app_label="mks", model="member") | ||
proposal = kwargs['instance'] | ||
if str(kwargs['sender']).find('proposers')>=0: | ||
if str(kwargs['sender']).find('proposers') >= 0: | ||
verb = 'proposed' | ||
else: | ||
verb = 'joined' | ||
for mk_id in kwargs['pk_set']: | ||
if Action.objects.filter(actor_object_id=mk_id, actor_content_type=member_ct, verb=verb, target_object_id=proposal.id, | ||
target_content_type=private_proposal_ct).count()==0: | ||
if Action.objects.filter(actor_object_id=mk_id, actor_content_type=member_ct, verb=verb, | ||
target_object_id=proposal.id, | ||
target_content_type=private_proposal_ct).count() == 0: | ||
mk = Member.objects.get(pk=mk_id) | ||
action.send(mk, verb=verb, target=proposal, timestamp=proposal.date) | ||
|
||
|
||
m2m_changed.connect(record_bill_proposal, sender=PrivateProposal.proposers.through) | ||
m2m_changed.connect(record_bill_proposal, sender=PrivateProposal.joiners.through) # same code handles both events | ||
m2m_changed.connect(record_bill_proposal, sender=PrivateProposal.joiners.through) # same code handles both events | ||
|
||
|
||
@disable_for_loaddata | ||
def record_vote_action(sender, created, instance, **kwargs): | ||
if created: | ||
action.send(instance.member, verb='voted', | ||
description=instance.get_type_display(), | ||
target = instance.vote, | ||
target=instance.vote, | ||
timestamp=instance.vote.time) | ||
post_save.connect(record_vote_action, sender=VoteAction, | ||
dispatch_uid='vote_action_record_member' ) | ||
|
||
|
||
post_save.connect(record_vote_action, sender=VoteAction, | ||
dispatch_uid='vote_action_record_member') | ||
|
||
|
||
@disable_for_loaddata | ||
def handle_candiate_list_save(sender, created, instance, **kwargs): | ||
if instance._state.db=='default': | ||
if instance._state.db == 'default': | ||
CandidateListVotingStatistics.objects.get_or_create(candidates_list=instance) | ||
|
||
|
||
post_save.connect(handle_candiate_list_save, sender=CandidateList) | ||
|
||
|
||
@disable_for_loaddata | ||
def handle_party_save(sender, created, instance, **kwargs): | ||
if created and instance._state.db=='default': | ||
if created and instance._state.db == 'default': | ||
PartyVotingStatistics.objects.get_or_create(party=instance) | ||
|
||
|
||
post_save.connect(handle_party_save, sender=Party) | ||
|
||
|
||
@disable_for_loaddata | ||
def handle_mk_save(sender, created, instance, **kwargs): | ||
if created and instance._state.db=='default': | ||
if created and instance._state.db == 'default': | ||
MemberVotingStatistics.objects.get_or_create(member=instance) | ||
|
||
|
||
post_save.connect(handle_mk_save, sender=Member) | ||
|
||
|
||
def add_tags_to_bill_related_objects(sender, instance, **kwargs): | ||
bill_ct = ContentType.objects.get_for_model(instance) | ||
for ti in TaggedItem.objects.filter(content_type=bill_ct, object_id=instance.id): | ||
add_tags_to_related_objects(sender, ti, **kwargs) | ||
|
||
post_save.connect(add_tags_to_bill_related_objects, sender=Bill) |
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,3 +1,4 @@ | ||
# encoding: utf-8 | ||
from __future__ import print_function | ||
|
||
from django.core.management.base import BaseCommand | ||
|
1 change: 1 addition & 0 deletions
1
laws/management/commands/recalculate_votes_properties_current_knesset.py
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,3 +1,4 @@ | ||
# encoding: utf-8 | ||
from __future__ import print_function | ||
|
||
from django.core.management.base import BaseCommand | ||
|
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
Oops, something went wrong.