Skip to content

Commit

Permalink
more changes for sprint #5
Browse files Browse the repository at this point in the history
  • Loading branch information
amir99 committed Dec 31, 2013
1 parent ae7f14f commit 8ae5013
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 30 deletions.
41 changes: 32 additions & 9 deletions src/communities/templates/communities/upcoming.html
Original file line number Diff line number Diff line change
Expand Up @@ -156,16 +156,39 @@ <h2 class="pull-left">{% trans "Summary" %}</h2>

<div id="available-agenda" class="agenda-list">
<h2>{% trans "Available Issues" %}</h2>

<ul id="available" class="nav nav-pills nav-stacked">
{% for i in object.available_issues %}
{% include "communities/_issue.html" %}
{% endfor %}
</ul>
{% if community.issue_ranking_enabled %}
<ul id="issues-order" class="nav nav-tabs">
<span style="float:right;margin-left: 2px;line-height: 1.428571429;border: 1px solid transparent;padding:10px 15px;font-weight:bold;">{% trans "Sort" %}</span>
<li class="active"><a href="#by_time" data-toggle="tab">{% trans "By time" %}</a></li>
<li><a href="#by_rank" data-toggle="tab">{% trans "By rank" %}</a></li>
</ul>
<div class="tab-content">
<div id="by_time" class="tab-pane active">
<ul id="available" class="nav nav-pills nav-stacked">
{% for i in object.available_issues %}
{% include "communities/_issue.html" %}
{% endfor %}
</ul>
</div>
<div id="by_rank" class="tab-pane">
<ul id="available" class="nav nav-pills nav-stacked">
{% for i in object.available_issues %}
{% include "communities/_issue.html" %}
{% endfor %}
</ul>
</div>
</div>

{% else %}
<ul id="available" class="nav nav-pills nav-stacked">
{% for i in object.available_issues %}
{% include "communities/_issue.html" %}
{% endfor %}
</ul>
{% endif %}

</div>

{% endif %}

{% endif %}
{% else %}

<div class="notice text-center">
Expand Down
9 changes: 2 additions & 7 deletions src/communities/templates/emails/_protocol.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,10 @@ <h2 style="margin:0; background: #ddd;padding: 4px">{% trans "Meeting Details" %
<div style="margin:0; padding: 4px">
<b>{% trans "Scheduled at" %}:</b>
{{ scheduled_at|default:_("Not set yet") }}

{% if location %}
<br/>
<b>{% trans "Location" %}:</b>
<br/>
<b>{% trans "Location" %}:</b> {{ location }}
{% endif %}

{% if summary %}
<br/>
<b>{% trans "Summary" %}:</b>
Expand Down Expand Up @@ -92,9 +90,6 @@ <h3 style="margin:0; background: #ddd;padding: 4px; font-size: 20px;">
</h3>

{% if a.comments.count or a.issue.attachments.count %}
<h4 style="margin:0; background: #eee; padding: 2px">
{% trans "Discussion Summary" %}
</h4>

{% if a.issue.attachments.count %}
<div class="issue_attachments">
Expand Down
11 changes: 5 additions & 6 deletions src/issues/shultze_vote.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ def user_vote(community_id, current_vote, prev_vote):
if prev_vote:
g.add_ballots(prev_vote,reverse=True)
g.add_ballots(current_vote)
print g.get_schulze_npr_results()


def set_issues_order_by_votes(community_id):
Expand All @@ -26,11 +25,11 @@ def set_issues_order_by_votes(community_id):
except IssuesGraph.DoesNotExist:
raise
res = g.get_schulze_npr_results()
issues_order = Issue.objects.in_bulk(res['order'])
for i, obj in enumerate(issues_order.values()):
obj.order_by_votes = i
print '[', i, '] ', obj
obj.save()
issues = Issue.objects.in_bulk(res['order'])
for idx, id in enumerate(res['order']):
issues[id].order_by_votes = idx
print '[', idx, '] ', issues[id]
issues[id].save()


def send_issue_ranking(request):
Expand Down
13 changes: 10 additions & 3 deletions src/issues/stubs/order_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def process_vote_stub(current_order, prev_order):
issues[id].order_by_votes = ord
issues[id].save()

def save_vote(request):
def send_issue_ranking(request):
if request.POST:
current_vote = json.loads(request.POST.get('new_order'))
prev_vote = IssueRankingVote.objects.filter(
Expand All @@ -31,17 +31,24 @@ def save_vote(request):
.order_by('rank')

if current_vote:
prev_param = {'ballot': [], 'count': 1, }
current_param = {'ballot': [], 'count': 1, }
prev_vote_as_list = list(prev_vote.values_list('issue_id', flat=True))
for v in prev_vote:
v.delete()

for v in prev_vote_as_list:
prev_param['ballot'].append([v])

for i, v in enumerate(current_vote):
IssueRankingVote.objects.create(
voted_by=request.user,
issue_id=v,
rank=i
)
print current_vote, prev_vote_as_list
process_vote_stub(current_vote, prev_vote)
current_param['ballot'].append([v])
print current_param, prev_param
# process_vote_stub(current_vote, prev_vote)
return HttpResponse(json_response('ok'))


Expand Down
8 changes: 5 additions & 3 deletions src/issues/templates/issues/issue_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h2> {% trans "Issues for discussion" %} </h2>
$('#ordered').on('click', '.addremove', function() {
var el = $(this).parent().parent();
el.addClass('loading');
$("#voted_out").append(el);
$("#voted_out").prepend(el);
// activate send button
enable_send_button();
});
Expand All @@ -171,8 +171,10 @@ <h2> {% trans "Issues for discussion" %} </h2>
community_id: '{{ community.id }}',
},
function(p){
disable_send_button();
});
// disable_send_button();
});

disable_send_button();
});
});
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/issues/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def get_context_data(self, **kwargs):
i.issue.status != IssueStatus.ARCHIVED]
all_issues_set = set(list(d['sorted_issues']))
d['my_non_ranked'] = list(all_issues_set - set(d['my_vote']))
print all_issues_set, set(d['my_vote'])
# print all_issues_set, set(d['my_vote'])
# d['can_rank_issues'] = can_rank_issues
return d

Expand Down
2 changes: 1 addition & 1 deletion src/meetings/static/js/upcoming.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ $(function() {
var el = $(this).parent().parent();
el.addClass('loading');
//console.log(el)
$("#available").append(el);
$("#available").prepend(el);
toggleIssue(el, 1);
}).sortable({
'containment': $('#agenda').parent().parent(),
Expand Down

0 comments on commit 8ae5013

Please sign in to comment.