Commits

Anonymous committed e573365

デザイン以外はほぼ完了

Comments (0)

Files changed (10)

+============
+TODO
+============
+
+- Account のバリデーション
+- account_name のバリデーション
+- followers/followings の実装
+- protected の実装
+- Account の変更/削除
+- Status の削除
+- 画像のアップロード
+- reply 機能の実装
+- お気に入り機能の実装
 # vim: fileencoding=utf8
 
-from django import newforms as forms
-
 from google.appengine.api import users
 from google.appengine.ext.db import djangoforms
 
 # manually, move them above the marker line.  The index.yaml file is
 # automatically uploaded to the admin console when you next deploy
 # your application using appcfg.py.
+
+# Used 3 times in query history.
+- kind: Status
+  properties:
+  - name: created
+    direction: desc

templates/account.html

-<form method="POST" action="/account/">
-  <table>
-    {{ form }}
-  </table>
-  <p><input type="submit" value="submit" /></p>
-</form>
-{% for account in accounts %}
-<div>{{ account.created }}, {{ account.account_name }}, {{ account.user.email }}</div>
-{% endfor %}
+{% extends "base.html" %}
+{% block title %}Account{% endblock %}
+{% block body %}
+  <form method="POST" action="/account/">
+    <table>
+      {{ form }}
+    </table>
+    <p><input type="submit" value="submit" /></p>
+  </form>
+  {% for account in accounts %}
+  <div>{{ account.created }}, {{ account.account_name }}, {{ account.user.email }}</div>
+  {% endfor %}
+{% endblock %}

templates/base.html

 <html>
 <head>
-  <title>{{ }}</title>
+  <title>{% block title %}monologista{% endblock %}</title>
 </head>
 <body>
-{% if not public_timeline %}
-まだステータスが一つも存在しません
-{% endif %}
-{% for status in public_timeline %}
-  {{ status.account.account_name }}, {{ status.text }} <br />
-{% endfor %}
+  {% block body %}
+  {% endblock %}
 </body>
 </html>
-

templates/home_timeline.html

-<form method="POST" action="/home/">
-  {{ form }}
-  <input type="submit" value="submit" /><br />
-</form>
-{% for status in home_timeline %}
-  {{ status.account.account_name }}, {{ status.text }} <br />
-{% endfor %}
+{% extends "base.html" %}
+{% block body %}
+  <form method="POST" action="/home/">
+    {{ form }}
+    <input type="submit" value="submit" /><br />
+  </form>
+  {% for status in home_timeline %}
+    {{ status.account.account_name }}, {{ status.text }} <br />
+  {% endfor %}
+{% endblock %}

templates/public_timeline.html

-<html>
-<head>
-  <title>monologista</title>
-</head>
-<body>
-{% for status in public_timeline %}
-  {{ status.account.account_name }}, {{ status.text }} <br />
-{% endfor %}
-</body>
-</html>
+{% extends "base.html" %}
+{% block title %}
+Public Timeline
+{% endblock %}
+{% block body %}
+  {% for status in public_timeline %}
+  {{ status.key.id }}, {{ status.account.account_name }}, {{ status.text }}<br />
+  {% endfor %}
+{% endblock %}

templates/status_detail.html

+{% extends "base.html" %}
+{% block body %}
+{{ oneself.account_name }}<br />
+{{ status.key.id }}, {{ status.account.account_name }}, {{ status.text }}
+{% endblock %}
+

templates/user_timeline.html

+{% extends "base.html" %}
+{% block title %}{{ account.account_name }} Timeline{% endblock %}
+{% block body %}
+  {% for status in user_timeline %}
+    {{ status.key.id }}, {{ status.account.account_name }}, {{ status.text }}<br />
+  {% endfor %}
+{% endblock %}
 # vim: fileencoding=utf8
 
 import os
+import logging
 
 from google.appengine.ext import webapp
 from google.appengine.ext import db
     return render_to_response(self, dictionary, 'account.html')
 
   def post(self):
+    """
+    """
     form = AccountForm(data=self.request.POST)
     if form.is_valid():
       account = form.save(commit=False)
 
 class PublicTimelineHandler(webapp.RequestHandler):
   """
-  {{ oneself.account_name }}
   {% for status in public_timeline %}
     {{ status.text }}
     {{ status.creatd }}
 
 class HomeTimelineHandler(webapp.RequestHandler):
   """
-  {{ oneself.account_name }}
   {% for status in home_timeline %}
-    {{ status.text }}
-    {{ status.creatd }}
+    {{ status.text }}, {{ status.creatd }}
   {% endfor %}
   """
   def get(self):
     oneself = get_account_from_user(user)
     if not user or not oneself:
       return self.redirect("/")
-    home_timeline = Status.all()
+    home_timeline = Status.all().order('-created')
     form = StatusForm()
     dictionary = {
       'home_timeline': home_timeline,
     oneself = get_account_from_user(user)
     if not user or not oneself:
       return self.redirect('/')
-    form = AccountForm(data=self.request.POST)
+    form = StatusForm(data=self.request.POST)
     if form.is_valid():
       status = form.save(commit=False)
+      status.account = oneself
       db.put(status)
       return self.redirect('/home/')
     home_timeline = Status.all()
 class StatusDetailHandler(webapp.RequestHandler):
   def get(self, account_name, status_id):
     """
-    {{ oneself.account_name }}
-    {{ status.account.account_name }}
-    {{ status.key.id }}
+    {{ status.account.account_name }}, {{ status.key.id }}, {{ status.text }}
     """
-    status = Status.get_by_id(status_id)
+    try:
+      status = Status.get_by_id(int(status_id))
+    except ValueError:
+      self.error(404)
+      return self.response.out.write('404')
     if not status:
       self.error(404)
       return self.response.out.write('404')
 
 class UserTimelineHandler(webapp.RequestHandler):
   """
-  {% if oneself %}
-    {{ oneself.account_name }}
-    {{ logout }}
-  {% else %}
-    {{ login }}
-  {% endif %}
   {% for status in user_timeline %}
-    {{ status.text }}
-    {{ status.creatd }}
-    {{ status.tags }}
+    {{ status.key.id }}, {{ status.text }}, {{ status.creatd }}
   {% endfor %}
   """
   def get(self, account_name):