Skip to content

Commit

Permalink
Commit attempt for course list viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Brockbank committed Aug 27, 2012
2 parents 698a52a + 4d6d386 commit c8c57df
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
2 changes: 1 addition & 1 deletion deme_django/cms/templates/collection/show.html
Expand Up @@ -38,7 +38,7 @@
$("#jqgrid_list_collection_{{ item.pk }}").jqGrid({
url: '{% url item_type_url viewer="item",action="grid",format="json" %}',
postData: {
fields: ['name'],
fields: 'name',
filter: 'memberships.collection.{{ item.pk }}',
},
datatype: "json",
Expand Down
Expand Up @@ -3,9 +3,14 @@
{% load air_extras %}
{% block content %}

<div style="font-weight: bold; font-size: larger;">Ongoing discussions</div>
{% ifagentcan 'comment_on' item %}
<div><a href="{% url item_url viewer="discussionboard",action="newdiscussion",noun=item.pk %}" style="text-decoration: underline;">Create a new discussion</a></div>
<div style="margin-bottom: 2em;">
<div style="float: right;">
<a href="{% url item_url viewer="discussionboard",action="newdiscussion",noun=item.pk %}" class="fg-button ui-widget ui-state-default ui-corner-all" style="background: #ffcc99;">Create a new discussion</a></div>
<div style="clear: both;"></div>
</div>
<div style="clear: both;"></div>
</div>
{% endifagentcan %}

<table style="border: 2px solid #000;">
Expand Down Expand Up @@ -37,6 +42,10 @@
{% endfor %}
</table>

{% endblock content %}
{% ifagentcan 'comment_on' item %}
<div><a href="{% url item_url viewer="discussionboard",action="newdiscussion",noun=item.pk %}" class="fg-button ui-widget ui-state-default ui-corner-all" style="background: #ffcc99;">Create a new discussion</a></div>
<div style="clear: both;"></div>
{% endifagentcan %}

{% endblock content %}

42 changes: 39 additions & 3 deletions deme_django/modules/community_forum/templatetags/air_extras.py
Expand Up @@ -40,7 +40,7 @@ def add_comment_to_div(comment_info, parents):
result.append(u'<div><input type="submit" value="Submit reply" /></div><input type="hidden" name="item" value="%s" /><input type="hidden" name="item_version_number" value="%s" />' % (comment.pk, comment.version_number))
result.append(u'</form></div>')
result.append(u'<div style="margin-bottom: 10px;">')
result.append(u'<div style="float: right; font-size: smaller;"><a href="#" onclick="$(\'#comment%s\').show(); return false;" class="fg-button ui-state-default fg-button-icon-left ui-corner-all"><span class="ui-icon ui-icon-comment"></span>Reply</a></div>' % comment.pk)
result.append(u'<div style="float: right;"><a href="#" onclick="$(\'#comment%s\').show(); return false;" class="fg-button ui-widget ui-state-default fg-button-icon-left ui-corner-all" style="background: #ffcc99;"><span class="ui-icon ui-icon-comment"></span>Reply</a></div>' % comment.pk)
if agentcan_helper(context, 'view Item.created_at', comment):
result.append('<div style="font-style: italic;">%s</div>' % comment.created_at.strftime("%a %b %d %Y %I:%M %p"))
result.append(u'<div style="clear: both;"></div>')
Expand Down Expand Up @@ -79,7 +79,7 @@ def render(self, context):
if viewer.cur_agent.is_anonymous():
login_menu_text = 'Login'
else:
login_menu_text = u'%s [Logout]' % get_viewable_name(context, viewer.cur_agent)
login_menu_text = u'Click here to log out <!-- %s -->' % get_viewable_name(context, viewer.cur_agent)

result.append("""
<script type="text/javascript">
Expand All @@ -100,7 +100,7 @@ def render(self, context):
});
});
</script>
<a href="#" class="fg-button fg-button-icon-right ui-widget ui-state-default ui-corner-all" id="login_menu_link"><span class="ui-icon ui-icon-triangle-1-s"></span>%s</a>
<a href="#" class="fg-button ui-widget ui-state-default ui-corner-all" id="login_menu_link">%s</a>
<ul id="simple_login_menu_ul" style="display: none;">
""" % login_menu_text)
for viewer_class in [CommunityForumParticipantViewer]:
Expand Down Expand Up @@ -139,3 +139,39 @@ def initial_font_size(parser, token):
if len(bits) != 1:
raise template.TemplateSyntaxError, "%r takes no arguments" % bits[0]
return InitialFontSize()


class IfAirGroup(template.Node):
def __init__(self, ids, nodelist_in, nodelist_out):
self.ids = [template.Variable(x) for x in ids]
self.nodelist_in, self.nodelist_out = nodelist_in, nodelist_out

def __repr__(self):
return "<IfAirGroup>"

def render(self, context):
try:
ids = [x.resolve(context) for x in self.ids]
except template.VariableDoesNotExist:
if settings.DEBUG:
return "[Couldn't resolve ids variable]"
else:
return '' # Fail silently for invalid variables.
viewer = context['_viewer']
print ids
in_group = RecursiveMembership.objects.filter(parent__in=ids, child=viewer.cur_agent).exists()
nodelist = self.nodelist_in if in_group else self.nodelist_out
return nodelist.render(context)

@register.tag
def ifairgroup(parser, token):
bits = list(token.split_contents())
end_tag = 'end' + bits[0]
nodelist_in = parser.parse(('else', end_tag))
token = parser.next_token()
if token.contents == 'else':
nodelist_out = parser.parse((end_tag,))
parser.delete_first_token()
else:
nodelist_out = template.NodeList()
return IfAirGroup(bits[1:], nodelist_in, nodelist_out)
2 changes: 1 addition & 1 deletion deme_django/modules/community_forum/views.py
Expand Up @@ -54,7 +54,7 @@ class DiscussionBoardViewer(ItemViewer):
viewer_name = 'discussionboard'

def item_show_html(self):
self.context['action_title'] = 'View ongoing discussions'
self.context['action_title'] = ''
template = loader.get_template('discussionboard/show.html')
top_level_comments = list(TextComment.objects.filter(item=self.item))
last_posts = {}
Expand Down
9 changes: 6 additions & 3 deletions deme_django/modules/poll/templates/poll/approvenpoll.html
Expand Up @@ -198,7 +198,7 @@
{% if propositions %}
<form method="post" enctype="multipart/form-data"
action="{% url item_url viewer=viewer_name,action="respondtopropositions",noun=item.pk %}?redirect={{ full_path|urlencode }}">
<div class="container propositions" id="Propcontainer" style="width: 78%; margin-left: 0; ">
<div class="container propositions" id="Propcontainer" style="width: 78%; margin-left: 3em; ">


{% for proposition in propositions %}
Expand Down Expand Up @@ -227,10 +227,13 @@

{% if cur_agent_in_eligbles %}
</div>
<!--
<p><strong>You also have the option of writing in your own statement that you think better captures your opinions. We ask that you still vote for each response above and then write your own statement here:</strong><p>
<textarea name="optional_writein_comment" type="text" cols="20" rows="2"></textarea><br />
-->
<input type="hidden" name="optional_writein_comment" value="" />
<div style="margin-left:40%; margin-bottom:1em;">
<input type="submit" value="Submit" /><br><br>
<button type="submit" class="fg-button ui-widget ui-state-default ui-corner-all" style="background: #ffcc99;">Submit</button><br><br>
</div>
{% endif %}
</form>
Expand Down Expand Up @@ -377,7 +380,7 @@ <h3>----------Results Page for Participants----------</h3>
</div>

{% if cur_agent_in_eligbles %}
<p><strong>Add another personal statement:</strong><p>
<p><strong>Add a personal statement:</strong><p>
<form method="post" enctype="multipart/form-data"
action="{% url item_url viewer=viewer_name,action="addawritein",noun=item.pk %}?redirect={{ full_path|urlencode }}">
<textarea name="optional_writein_comment" type="text" cols="20" rows="2"></textarea><br />
Expand Down
6 changes: 3 additions & 3 deletions deme_django/modules/poll/views.py
Expand Up @@ -154,10 +154,10 @@ def item_show_html(self):
#maxTemp = max([agree, disagree, no_vote])
no_vote = n-agree-disagree
#if(maxTemp > maxNumber): maxNumber = maxTemp
vote_numbers.append({'agree': int(agree), 'n':range(n), 'agreeList':range(agree), 'disagree': int(disagree), 'disagreeList': range(disagree), 'no_vote':int(no_vote), 'no_voteList':range(no_vote), 'proposition': proposition})
vote_numbers.append({'agree': int(agree), 'n':range(int(n)), 'agreeList':range(int(agree)), 'disagree': int(disagree), 'disagreeList': range(int(disagree)), 'no_vote':int(no_vote), 'no_voteList':range(int(no_vote)), 'proposition': proposition})

#self.context['maxVal'] = maxNumber
self.context['rangeN'] = range(n+1)
self.context['rangeN'] = range(int(n)+1)
self.context['proportion'] = int(12.0*15.0/n)
self.context['2proportion'] = 2*int(12.0*15.0/n)
self.context['vote_numbers_list'] = vote_numbers
Expand Down Expand Up @@ -238,7 +238,7 @@ def item_respondtopropositions_html(self):
#if(maxTemp > maxNumber): maxNumber = maxTemp
no_vote = 12-agree-disagree
#if(maxTemp > maxNumber): maxNumber = maxTemp
vote_numbers.append({'agree': agree, 'agreeList': range(agree), 'disagree': disagree, 'disagreeList': range(disagree), 'no_vote':no_vote, 'no_voteList':range(no_vote), 'proposition': proposition})
vote_numbers.append({'agree': agree, 'agreeList': range(int(agree)), 'disagree': disagree, 'disagreeList': range(int(disagree)), 'no_vote':no_vote, 'no_voteList':range(int(no_vote)), 'proposition': proposition})

#self.context['maxVal'] = maxNumber
self.context['vote_numbers_list'] = vote_numbers
Expand Down

0 comments on commit c8c57df

Please sign in to comment.