Skip to content

Commit

Permalink
Makes feedback public on team page
Browse files Browse the repository at this point in the history
  • Loading branch information
akdotcom committed Oct 3, 2011
1 parent a0226c5 commit 9d316a8
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 13 deletions.
15 changes: 13 additions & 2 deletions main.py
Expand Up @@ -18,6 +18,7 @@

config = { 'enable_voting': False,
'enable_commenting': True,
'show_comments': True,
'enable_team_editing': True,
'enable_team_adding': False,
'list_teams_randomly': True,
Expand Down Expand Up @@ -53,6 +54,10 @@ def shouldEnableCommenting():
return config['enable_commenting'] and checkAdmin(users.get_current_user().email())


def generateCommentAuthorName(comment):
return comment.user.nickname().split('@', 1)[0]


class BaseHandler(webapp.RequestHandler):
def render(self, template_name, template_values):
path = os.path.join(os.path.dirname(__file__), 'templates/%s.html' % template_name)
Expand Down Expand Up @@ -179,7 +184,7 @@ def get(self):
comments = Comment.all()
for comment in comments:
team_key = str(comment.team.key())
comment.author_name = comment.user.nickname().split('@', 1)[0]
comment.author_name = generateCommentAuthorName(comment)
if not team_key in team_comments:
team_comments[team_key] = []
if comment.user == current_user:
Expand Down Expand Up @@ -276,7 +281,13 @@ def get(self):
team = Team.get(team_key)
votes = Votes.for_user(users.get_current_user())
team.voted = (team.key() in votes.local_teams or team.key() in votes.teams)
self.render('team', { 'team': team })
if config['show_comments']:
team.comments = list(Comment.get_team_comments(team))
for comment in team.comments:
comment.author_name = generateCommentAuthorName(comment)

self.render('team', { 'team': team,
'show_comments': config['show_comments']})


application = webapp.WSGIApplication([('/', ListProjects),
Expand Down
2 changes: 2 additions & 0 deletions model.py
Expand Up @@ -58,10 +58,12 @@ def get_comment(user, team):
return None
@staticmethod
def get_team_comments(team):
"""Remember, this returns a query stream, not a mutable list!"""
query = db.Query(Comment)
return query.filter('team =', team)
@staticmethod
def get_user_comments(user):
"""Remember, this returns a query stream, not a mutable list!"""
query = db.Query(Comment)
return query.filter('user =', user)

Expand Down
23 changes: 12 additions & 11 deletions templates/list.html
Expand Up @@ -169,17 +169,18 @@ <h3>Feedback</h3>
</form>
</div>

<h3>Winning Honor (ak only, please)</h3>
<div class="comment_entry">
<form action="annotate" method="POST">
<input type="hidden" name="team_key" value="{{ team.key }}"/>
<textarea rows="5" cols="39" name="text"
>{% if team.annotation %}{{ team.annotation }}{% endif %}</textarea>
<br/>
<input type=submit value="submit" />
</form>
</div>

{% if show_winner_entry %}
<h3>Winning Honor (ak only, please)</h3>
<div class="comment_entry">
<form action="annotate" method="POST">
<input type="hidden" name="team_key" value="{{ team.key }}"/>
<textarea rows="5" cols="39" name="text"
>{% if team.annotation %}{{ team.annotation }}{% endif %}</textarea>
<br/>
<input type=submit value="submit" />
</form>
</div>
{% endif %}
<form action="hide" method="POST">
<input type="hidden" name="team_key" value="{{ team.key }}"/>
Hidden?
Expand Down
10 changes: 10 additions & 0 deletions templates/team.html
Expand Up @@ -70,6 +70,16 @@ <h3>Feedback</h3>
</div>
</div>
{% endif %}
{% if show_comments %}
<div class="comments">
<h3>Feedback</h3>
{% for comment in team.comments %}
<span><b>{{ comment.author_name|escape }}</b></span>:
<span>{{ comment.text|escape }}</span>
<br/>
{% endfor %}
</div>
{% endif %}
</div>
</div>

Expand Down

0 comments on commit 9d316a8

Please sign in to comment.