Skip to content
This repository has been archived by the owner on Apr 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #529 from OriHoch/PR517-multiple-issues-by-alon-ni…
Browse files Browse the repository at this point in the history
…sser

PR #517 - multiple issues by alon nisser
  • Loading branch information
OriHoch committed Feb 14, 2016
2 parents ee611cb + de43d47 commit fd25e97
Show file tree
Hide file tree
Showing 27 changed files with 1,688 additions and 637 deletions.
16 changes: 8 additions & 8 deletions agendas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def update_monthly_counters(self):
if agendaSummary:
newObjects.append(agendaSummary)
voters = defaultdict(list)
for vote_action in self.vote.voteaction_set.all():
for vote_action in self.vote.actions.all():
mkSummary = agendasByMk.get(vote_action.member_id, None)
if not mkSummary:
mkSummary = SummaryAgenda(month=objMonth,
Expand Down Expand Up @@ -364,10 +364,10 @@ def party_score(self, party):
# Since we're already calculating python side, no need to do 2 queries
# with joins, select for and against, and calcualte the things
qs = AgendaVote.objects.filter(
agenda=self, vote__voteaction__member__in=party.members.all(),
vote__voteaction__type__in=['against', 'for']).extra(
agenda=self, vote__actions__member__in=party.members.all(),
vote__actions__type__in=['against', 'for']).extra(
select={'weighted_score': 'agendas_agendavote.score*agendas_agendavote.importance'}
).values_list('weighted_score', 'vote__voteaction__type')
).values_list('weighted_score', 'vote__actions__type')

for_score = 0
against_score = 0
Expand Down Expand Up @@ -395,10 +395,10 @@ def candidate_list_score(self, candidate_list):
# Since we're already calculating python side, no need to do 2 queries
# with joins, select for and against, and calcualte the things
qs = AgendaVote.objects.filter(
agenda=self, vote__voteaction__member__in=candidate_list.member_ids,
vote__voteaction__type__in=['against', 'for']).extra(
agenda=self, vote__actions__member__in=candidate_list.member_ids,
vote__actions__type__in=['against', 'for']).extra(
select={'weighted_score': 'agendas_agendavote.score*agendas_agendavote.importance'}
).values_list('weighted_score', 'vote__voteaction__type')
).values_list('weighted_score', 'vote__actions__type')

for_score = 0
against_score = 0
Expand Down Expand Up @@ -429,7 +429,7 @@ def related_mk_votes(self,member):
# for_votes = AgendaVote.objects.filter(agenda=self,vote__voteaction__member=member,vote__voteaction__type="for").distinct()
#against_votes = AgendaVote.objects.filter(agenda=self,vote__voteaction__member=member,vote__voteaction__type="against").distinct()
vote_actions = VoteAction.objects.filter(member=member,vote__agendavotes__agenda=self)
all_votes = AgendaVote.objects.filter(agenda=self,vote__voteaction__member=member).distinct()
all_votes = AgendaVote.objects.filter(agenda=self,vote__actions__member=member).distinct()
# TODO: improve ugly code below
member_votes = list()
for member_vote in all_votes:
Expand Down
196 changes: 98 additions & 98 deletions agendas/tests.py

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions agendas/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def get_context(self, *args, **kwargs):
cache.set('AllAgendaPartyVotes', allAgendaPartyVotes, 1800)

if self.request.user.is_authenticated():
p = self.request.user.get_profile()
p = self.request.user.profiles.get()
watched = p.agendas
else:
watched = None
Expand Down Expand Up @@ -114,9 +114,9 @@ def get_context_data(self, *args, **kwargs):
context['title'] = _('None')

if self.request.user.is_authenticated():
p = self.request.user.get_profile()
p = self.request.user.profiles.get()
watched = agenda in p.agendas
watched_members = self.request.user.get_profile().members
watched_members = self.request.user.profiles.get().members
else:
watched = False
watched_members = False
Expand Down Expand Up @@ -193,7 +193,7 @@ def get_context_data(self, *args, **kwargs):
ctx = super(AgendaVotesMoreView, self).get_context_data(*args, **kwargs)

if self.request.user.is_authenticated():
p = self.request.user.get_profile()
p = self.request.user.profiles.get()
watched_members = p.members
else:
watched_members = False
Expand Down Expand Up @@ -299,7 +299,7 @@ def get_context_data(self, *args, **kwargs):
related_mk_votes = agenda.related_mk_votes(member)

if self.request.user.is_authenticated():
p = self.request.user.get_profile()
p = self.request.user.profiles.get()
watched = agenda in p.agendas
else:
watched = False
Expand Down
16 changes: 10 additions & 6 deletions committees/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from models import Committee, CommitteeMeeting, Topic
from links.models import Link


class CommitteeRelatedVideosInline(generic.GenericTabularInline):
model = Video
ct_fk_field = 'object_pk'
Expand All @@ -22,16 +23,18 @@ def queryset(self, request):


class CommitteeAdmin(admin.ModelAdmin):
ordering = ('name', )
filter_horizontal = ('members','chairpersons','replacements')
inlines = (CommitteeRelatedVideosInline, )
ordering = ('name',)
filter_horizontal = ('members', 'chairpersons', 'replacements')
inlines = (CommitteeRelatedVideosInline,)


admin.site.register(Committee, CommitteeAdmin)


class CommitteeMeetingAdmin(admin.ModelAdmin):
ordering = ('-date', )
ordering = ('-date',)
list_display = ('__unicode__', 'date')
list_filter = ('committee',)


admin.site.register(CommitteeMeeting, CommitteeMeetingAdmin)
Expand All @@ -44,11 +47,12 @@ class LinksTable(GenericTabularInline):


class TopicAdmin(admin.ModelAdmin):
ordering = ('-created', )
ordering = ('-created',)
list_select_related = True
exclude = ('meetings', )
exclude = ('meetings',)
inlines = [
LinksTable,
]


admin.site.register(Topic, TopicAdmin)
29 changes: 25 additions & 4 deletions laws/admin.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,54 @@
from models import Vote,Law,PrivateProposal,KnessetProposal,GovProposal,Bill,GovLegislationCommitteeDecision
from models import Vote, Law, PrivateProposal, KnessetProposal, GovProposal, Bill, GovLegislationCommitteeDecision

from django.contrib import admin


class VoteAdmin(admin.ModelAdmin):
# filter_horizontal = ('voted_for','voted_against','voted_abstain','didnt_vote')
list_display = ('__unicode__','short_summary','full_text_link','for_votes_count','against_votes_count')
# filter_horizontal = ('voted_for','voted_against','voted_abstain','didnt_vote')
list_display = (
'__unicode__', 'short_summary', 'full_text_link', 'for_votes_count', 'against_votes_count', 'abstain_votes_count')


admin.site.register(Vote, VoteAdmin)


class LawAdmin(admin.ModelAdmin):
pass


admin.site.register(Law, LawAdmin)


class PrivateProposalAdmin(admin.ModelAdmin):
pass


admin.site.register(PrivateProposal, PrivateProposalAdmin)


class KnessetProposalAdmin(admin.ModelAdmin):
pass


admin.site.register(KnessetProposal, KnessetProposalAdmin)


class GovProposalAdmin(admin.ModelAdmin):
pass


admin.site.register(GovProposal, GovProposalAdmin)


class BillAdmin(admin.ModelAdmin):
pass


admin.site.register(Bill, BillAdmin)


class GovLegislationCommitteeDecisionAdmin(admin.ModelAdmin):
pass
admin.site.register(GovLegislationCommitteeDecision, GovLegislationCommitteeDecisionAdmin)


admin.site.register(GovLegislationCommitteeDecision, GovLegislationCommitteeDecisionAdmin)
Loading

0 comments on commit fd25e97

Please sign in to comment.