Skip to content

Commit

Permalink
Unique tags. Utf no uniq ? The hell is wrong with you people ? =/
Browse files Browse the repository at this point in the history
  • Loading branch information
zmack committed Sep 17, 2008
1 parent 26ff496 commit 98bd839
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 6 deletions.
22 changes: 20 additions & 2 deletions doeet.py
Expand Up @@ -71,10 +71,18 @@ def post(self):
todo.author = users.get_current_user()

todo.content = self.request.get('content')
todo.tags = [tag.strip() for tag in self.request.get('tags').split(',')]
todo.tags = self._get_tags(self.request.get('tags'))
todo.put()
self.redirect('/')

def _get_tags(self, tag_string):
tags = []
for tag in tag_string.split(','):
tag = tag.strip()
if not tag in tags:
tags.append(tag)
return tags

class GetTodo(webapp.RequestHandler):
def get(self, id):
todo = Todo.get(id)
Expand All @@ -97,12 +105,22 @@ def put(self, id):

self.response.out.write(todo.toJson())

class TodosByTag(webapp.RequestHandler):
def get(self, tag):
user = users.get_current_user()
path = os.path.join(os.path.dirname(__file__), 'templates', 'index.html')

todos = db.Query(Todo).filter('author =', user).filter('tags = ',tag).order('date_done').order('date_added')
self.response.out.write(template.render(path, { 'login_link': users.create_login_url('/'), 'user': user, 'todos': todos }))


application = webapp.WSGIApplication([
('/', MainPage),
('/todos', NewTodo),
('/todos/([^/]*)', GetTodo),
('/todos/([^/]*)/done', DoneTodo),
('/todos/([^/]*)/reopen', ReopenTodo)
('/todos/([^/]*)/reopen', ReopenTodo),
('/tags/([^/]*)', TodosByTag)
], debug=True)


Expand Down
10 changes: 9 additions & 1 deletion index.yaml
Expand Up @@ -16,9 +16,17 @@ indexes:
- name: date
direction: desc

# Used 2 times in query history.
# Used 12 times in query history.
- kind: Todo
properties:
- name: author
- name: date_done
- name: date_added

# Used 3 times in query history.
- kind: Todo
properties:
- name: author
- name: tags
- name: date_done
- name: date_added
6 changes: 3 additions & 3 deletions templates/index.html
@@ -1,9 +1,9 @@
<html>
<head>
<title>Do Eet !</title>
<link type="text/css" rel="stylesheet" href="stylesheets/style.css"/>
<script lang="Javascript" src="javascript/jquery-1.2.6.js"></script>
<script lang="Javascript" src="javascript/doeet-scripts.js"></script>
<link type="text/css" rel="stylesheet" href="/stylesheets/style.css"/>
<script lang="Javascript" src="/javascript/jquery-1.2.6.js"></script>
<script lang="Javascript" src="/javascript/doeet-scripts.js"></script>
</head>
<body>
<div id="current_user">
Expand Down

0 comments on commit 98bd839

Please sign in to comment.