Skip to content

Commit

Permalink
add group by date, visual spearators for list
Browse files Browse the repository at this point in the history
  • Loading branch information
billsaysthis committed Apr 19, 2010
1 parent a407c4a commit 89f263f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
3 changes: 3 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ class Update(db.Model):
def user_fullname(self):
return fullname(username(self.user))

def create_date(self):
return self.created.date()

class Comment(db.Model):
user = db.UserProperty(auto_current_user_add=True)
body = db.StringProperty(required=True)
Expand Down
4 changes: 3 additions & 1 deletion static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ h4 { font-size: smaller; }

.label { font-size: smaller; font-weight: bold; margin-top: 10px;}
#content h2 { margin-bottom: 5px; margin-top: 5px;}
#content table { margin-bottom: 20px;}
#content table { margin-bottom: 20px;}

.update-block {border-bottom: 1px solid #ff0000;}
35 changes: 21 additions & 14 deletions templates/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@
{% block content %}

<form method="post">
<textarea name="body"></textarea><br />
<input type="submit" value="Update" />
<textarea name="body" style="width: 300px;"></textarea><br />
<input type="submit" value="Add Log" />
</form>

{% for update in updates %}
<p>{{update.body}} | {{update.created|timesince}} ago | {{update.user_fullname}} |
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})" id="comment-link-{{update.key.id}}">Comment</a>
<form action="/comment/{{update.key.id}}" method="post" id="comment-form-{{update.key.id}}" style="display: none;">
<input type="text" name="body" /> <input type="submit" value="Comment" />
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})">Cancel</a>
</form>
</p>
{% for comment in update.comment_set %}
<p style="margin-left: 20px;">
{{comment.body}} | {{comment.created|timesince}} ago | {{comment.user_fullname}}
</p>
{% regroup updates by create_date as grouped_updates %}
{% for updates in grouped_updates %}
<h3>Recent Entries</h3>
<h4>{% ifequal updates.grouper today.date %}<span style="text-decoration:underline;">Today</span> - {% endifequal %}{{updates.grouper|date:"l, F j"}}</h4>
{% for update in updates.list %}
<div class='update-block'>
<p>{{update.body}} | posted {{update.created|timesince}} ago by {{update.user_fullname}} |
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})" id="comment-link-{{update.key.id}}">Comment</a>
<form action="/comment/{{update.key.id}}" method="post" id="comment-form-{{update.key.id}}" style="display: none;">
<input type="text" name="body" /> <input type="submit" value="Comment" />
<a href="javascript:void()" onclick="toggleComment({{update.key.id}})">Cancel</a>
</form>
</p>
{% for comment in update.comment_set %}
<p style="margin-left: 20px;">
{{comment.body}} | posted {{comment.created|timesince}} ago by {{comment.user_fullname}}
</p>
{% endfor %}
</div>
{% endfor %}
{% endfor %}

Expand Down

0 comments on commit 89f263f

Please sign in to comment.