Permalink
Browse files

Merge branch 'master' of git://github.com/nathanborror/django-basic-a…

…pps into nborror/master
  • Loading branch information...
2 parents 922f1bf + 35f3729 commit 15d7d597a12c99d18c7930e65c42f4704c7d7c0d @howiworkdaily howiworkdaily committed Jun 22, 2009
View
@@ -9,7 +9,7 @@ of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
-Neither the name of the haystack nor the names of its contributors may be
+Neither the name of the django-basic-apps nor the names of its contributors may be
used to endorse or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
@@ -40,7 +40,7 @@
div.setAttribute('style', 'margin-top:10px;');
div.innerHTML = content;
- body_div.insertBefore(div);
+ body_div.insertBefore(div, document.getElementById('id_body').nextSibling);
}
function insertInline(type, id, classname) {
View
@@ -20,45 +20,45 @@
>>> post2.categories.add(category2)
>>> response = client.get(reverse('blog_index'))
->>> response.context[-1]['object_list']
+>>> response.context[0]['object_list']
[<Post: DJ Ango>, <Post: Where my grails at?>]
>>> response.status_code
200
>>> response = client.get(reverse('blog_category_list'))
->>> response.context[-1]['object_list']
+>>> response.context[0]['object_list']
[<Category: Django>, <Category: Rails>]
>>> response.status_code
200
>>> response = client.get(category.get_absolute_url())
->>> response.context[-1]['object_list']
+>>> response.context[0]['object_list']
[<Post: DJ Ango>]
>>> response.status_code
200
>>> response = client.get(post.get_absolute_url())
->>> response.context[-1]['object']
+>>> response.context[0]['object']
<Post: DJ Ango>
>>> response.status_code
200
>>> response = client.get(reverse('blog_search'), {'q': 'DJ'})
->>> response.context[-1]['object_list']
+>>> response.context[0]['object_list']
[<Post: DJ Ango>]
>>> response.status_code
200
>>> response = client.get(reverse('blog_search'), {'q': 'Holy'})
->>> response.context[-1]['object_list']
+>>> response.context[0]['object_list']
[<Post: Where my grails at?>]
>>> response.status_code
200
>>> response = client.get(reverse('blog_search'), {'q': ''})
->>> response.context[-1]['message']
+>>> response.context[0]['message']
'Search term was too vague. Please try again.'
>>> response = client.get(reverse('blog_detail', args=[2008, 'apr', 2, 'where']))
->>> response.context[-1]['object']
+>>> response.context[0]['object']
<Post: Where my grails at?>
>>> response.status_code
200
@@ -11,7 +11,7 @@
{% block content %}
- <form action="{% url relationship_stop_follow to_user_id=to_user.id %}" method="post">
+ <form action="{% url relationship_unfollow to_user_id=to_user.id %}" method="post">
<p>Are you sure you want to delete {{ to_user }} as a friend?
<button type="submit" name="submit" value="Indeed">Indeed</button></p>
</form>
@@ -7,7 +7,7 @@
view=relationship_views.follow,
name='relationship_follow'),
- url(r'^stop-following/(?P<to_user_id>\d+)/$',
- view=relationship_views.stop_follow,
- name='relationship_stop_follow'),
+ url(r'^unfollow/(?P<to_user_id>\d+)/$',
+ view=relationship_views.unfollow,
+ name='relationship_unfollow'),
)
@@ -5,6 +5,7 @@
from django.contrib.auth.models import User
from django.contrib.auth.decorators import login_required
from django.db import models
+from django.utils import simplejson as json
Relationship = models.get_model('relationships', 'relationship')
@@ -18,8 +19,18 @@ def follow(request, to_user_id, template_name='relationships/relationship_add_co
relationship, created = Relationship.objects.get_or_create(from_user=from_user, to_user=to_user)
if request.is_ajax():
- context = "{'success': 'Success', 'to_user_id': '%s'}" % (to_user.id)
- return HttpResponse(context, mimetype="application/json")
+ response = {
+ 'success': 'Success',
+ 'to_user': {
+ 'username': to_user.username,
+ 'user_id': to_user.pk
+ },
+ 'from_user': {
+ 'username': from_user.username,
+ 'user_id': from_user.pk
+ }
+ }
+ return HttpResponse(json.dumps(response), mimetype="application/json")
else:
template_name = success_template_name
@@ -28,19 +39,29 @@ def follow(request, to_user_id, template_name='relationships/relationship_add_co
@login_required
-def stop_follow(request, to_user_id, template_name='relationships/relationship_delete_confirm.html', success_template_name='relationships/relationship_delete_success.html', mimetype='text/html'):
+def unfollow(request, to_user_id, template_name='relationships/relationship_delete_confirm.html', success_template_name='relationships/relationship_delete_success.html', mimetype='text/html'):
to_user = get_object_or_404(User, pk=to_user_id)
from_user = request.user
-
+
if request.is_ajax() or request.POST:
relationship = get_object_or_404(Relationship, to_user=to_user, from_user=from_user)
relationship.delete()
-
+
if request.is_ajax():
- context = "{'success': 'Success', 'to_user_id': '%s'}" % (to_user.id)
- return HttpResponse(context, mimetype="application/json")
+ response = {
+ 'success': 'Success',
+ 'to_user': {
+ 'username': to_user.username,
+ 'user_id': to_user.pk
+ },
+ 'from_user': {
+ 'username': from_user.username,
+ 'user_id': from_user.pk
+ }
+ }
+ return HttpResponse(json.dumps(response), mimetype="application/json")
else:
template_name = success_template_name
-
+
context = {'to_user': to_user}
return render_to_response(template_name, context, context_instance=RequestContext(request), mimetype=mimetype)

0 comments on commit 15d7d59

Please sign in to comment.