public
Description: Mobile FriendFeed Client
Homepage: http://www.fftogo.com/
Clone URL: git://github.com/bgolub/fftogo.git
now able to edit comments
bgolub (author)
Sat Jun 28 07:51:48 -0700 2008
commit  030062f151d806a74d9dc012585b3e4c233542e1
tree    90488a728e5cf13afb87b44cc069a30ae99814e5
parent  46f122fac6ce3636a83712673666d50f9081f183
...
7
8
9
 
10
11
12
...
7
8
9
10
11
12
13
0
@@ -7,6 +7,7 @@ class IntegerWidget(forms.TextInput):
0
 
0
 class CommentForm(forms.Form):
0
     body = forms.CharField(label='Comment', widget=forms.Textarea)
0
+ comment = forms.CharField(widget=forms.HiddenInput, required=False)
0
     entry = forms.CharField(widget=forms.HiddenInput)
0
     next = forms.CharField(widget=forms.HiddenInput)
0
 
...
1
 
2
3
 
 
 
 
 
4
5
6
...
1
2
3
4
5
6
7
8
9
10
11
12
0
@@ -1,6 +1,12 @@
0
 from django import template
0
+from google.appengine.api import memcache
0
 
0
 register = template.Library()
0
+
0
+@register.filter
0
+def can_edit(value):
0
+ key = 'comment_%s' % value['id']
0
+ return memcache.get(key)
0
  
0
 @register.filter
0
 def gmpize(value, arg=None):
...
82
83
84
85
 
 
 
 
 
86
87
88
89
90
 
 
91
92
93
94
95
 
 
 
 
 
96
97
98
...
100
101
102
 
 
 
 
103
104
105
...
82
83
84
 
85
86
87
88
89
90
91
92
93
94
95
96
97
 
 
 
 
98
99
100
101
102
103
104
105
...
107
108
109
110
111
112
113
114
115
116
0
@@ -82,17 +82,24 @@ def entry_comment(request, entry):
0
             f = friendfeed.FriendFeed(request.session['nickname'],
0
                 request.session['key'])
0
             try:
0
- comment = f.add_comment(form.data['entry'], form.data['body'], via=VIA)
0
+ if form.data['comment']:
0
+ f.edit_comment(form.data['entry'], form.data['comment'], form.data['body'])
0
+ comment = form.data['comment']
0
+ else:
0
+ comment = f.add_comment(form.data['entry'], form.data['body'], via=VIA)
0
             except Exception, e:
0
                 if e[0] == 401:
0
                     del request.session['nickname']
0
                     del request.session['key']
0
                 return HttpResponseRedirect(reverse(str(e)))
0
+ key = 'comment_%s' % comment
0
+ result = memcache.set(key, form.data['body'])
0
             next = form.data['next']
0
- if '?' in next:
0
- next = next + '&message=commented&entry=%s&comment=%s' % (entry, comment)
0
- else:
0
- next = next + '?message=commented&entry=%s&comment=%s' % (entry, comment)
0
+ if not form.data['comment']:
0
+ if '?' in next:
0
+ next = next + '&message=commented&entry=%s&comment=%s' % (entry, comment)
0
+ else:
0
+ next = next + '?message=commented&entry=%s&comment=%s' % (entry, comment)
0
             next = next + '#%s' % comment
0
             return HttpResponseRedirect(next)
0
     else:
0
@@ -100,6 +107,10 @@ def entry_comment(request, entry):
0
             'entry': entry,
0
             'next': request.GET.get('next', '/'),
0
         }
0
+ if 'comment' in request.GET:
0
+ key = 'comment_%s' % request.GET['comment']
0
+ initial['body'] = memcache.get(key)
0
+ initial['comment'] = request.GET['comment']
0
         form = CommentForm(initial=initial)
0
     extra_context = {
0
         'form': form,
...
120
121
122
123
124
 
 
 
 
 
 
 
125
126
127
128
 
129
130
131
...
120
121
122
 
 
123
124
125
126
127
128
129
130
131
 
 
132
133
134
135
0
@@ -120,12 +120,16 @@ Liked by {{ entry.likes|length|apnumber }} {{ entry.likes|length|pluralize:"pers
0
 -
0
 <span title="{{ comment.date }}">{{ comment.date|timesince }} ago</span>
0
 {% ifequal request.session.nickname comment.user.nickname %}
0
--
0
-<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">Delete</a>
0
+(
0
+{% if comment|can_edit %}
0
+<a href="{% url entry_comment entry.id %}?comment={{ comment.id }}&next={{ request.path }}">edit</a>
0
+|
0
+{% endif %}
0
+<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">delete</a>
0
+)
0
 {% else %}
0
 {% ifequal request.session.nickname entry.user.nickname %}
0
--
0
-<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">Delete</a>
0
+(<a href="{% url comment_delete entry.id,comment.id %}?next={{ request.path }}">delete</a>)
0
 {% endifequal %}
0
 {% endifequal %}
0
 </li>

Comments

    No one has commented yet.