Permalink
Browse files

clean up structure

  • Loading branch information...
1 parent bccc839 commit 8f8dd2cb5a51dc13f901258938c14f09bde20bca @tuxcanfly tuxcanfly committed Jul 5, 2010
Showing with 1,256 additions and 0 deletions.
  1. +2 −0 README
  2. +84 −0 example_project/LICENSE
  3. 0 example_project/__init__.py
  4. 0 example_project/commentor/__init__.py
  5. +4 −0 example_project/commentor/models.py
  6. +31 −0 example_project/commentor/templates/commentor/index.html
  7. +23 −0 example_project/commentor/tests.py
  8. 0 example_project/commentor/urls.py
  9. +22 −0 example_project/commentor/views.py
  10. +17 −0 example_project/example/README
  11. 0 example_project/example/__init__.py
  12. +5 −0 example_project/example/admin.py
  13. +12 −0 example_project/example/models.py
  14. +22 −0 example_project/example/templates/comments/example/form.html
  15. +10 −0 example_project/example/templates/comments/example/list.html
  16. +19 −0 example_project/example/templates/example/post_detail.html
  17. +16 −0 example_project/example/templates/example/post_list.html
  18. +23 −0 example_project/example/tests.py
  19. +9 −0 example_project/example/urls.py
  20. +15 −0 example_project/example/views.py
  21. +12 −0 example_project/example_comments/__init__.py
  22. +3 −0 example_project/example_comments/models.py
  23. +23 −0 example_project/example_comments/tests.py
  24. +8 −0 example_project/example_comments/views.py
  25. +246 −0 example_project/ez_setup.py
  26. +95 −0 example_project/localsettings.example.py
  27. +11 −0 example_project/manage.py
  28. +44 −0 example_project/media/css/openid.css
  29. +73 −0 example_project/media/css/socialauth.css
  30. BIN example_project/media/images/aol.gif
  31. BIN example_project/media/images/blogger.ico
  32. BIN example_project/media/images/claimid.ico
  33. BIN example_project/media/images/facebook.gif
  34. BIN example_project/media/images/flickr.ico
  35. BIN example_project/media/images/google.gif
  36. BIN example_project/media/images/linkedin.jpg
  37. BIN example_project/media/images/livejournal.ico
  38. BIN example_project/media/images/myopenid.ico
  39. BIN example_project/media/images/openid-inputicon.gif
  40. BIN example_project/media/images/openid.gif
  41. BIN example_project/media/images/technorati.ico
  42. BIN example_project/media/images/twitter.png
  43. BIN example_project/media/images/verisign.ico
  44. BIN example_project/media/images/vidoop.ico
  45. BIN example_project/media/images/wordpress.ico
  46. BIN example_project/media/images/yahoo.gif
  47. +32 −0 example_project/media/js/jquery-1.2.6.min.js
  48. +228 −0 example_project/media/js/openid-jquery.js
  49. +1 −0 example_project/openid_consumer
  50. +4 −0 example_project/requirements.txt
  51. +113 −0 example_project/settings.example.py
  52. +23 −0 example_project/setup.py
  53. +1 −0 example_project/socialauth
  54. +25 −0 example_project/urls.py
View
2 README
@@ -18,6 +18,8 @@ In particular it allows logging in via
Libs you need to install
See requirements.txt
+use `pip install -r requirements.txt` to install all dependencies at once
+
The API Keys are available from
View
@@ -0,0 +1,84 @@
+This work is dual licensed under
+
+(new)
+
+Copyright (c) 2009, Shabda Raaj and Contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list 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 <organization> 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 <copyright holder> ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+(To keep the older one around if in some remote chance you prefer this.)
+
+Copyright (c) 2009 by Shabda Raaj and Contributors
+* Usware Technologies
+* www.uswaretech.com
+"Building Amazing Webapps"
+
+All Rights Reserved
+Modified ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the conditions below are met.
+These conditions require a modest attribution to Author (the
+"Shabda Raaj"), who hopes that its promotional value may help justify the
+thousands of dollars in otherwise billable time invested in writing
+this and other freely available, open-source software.
+
+1. Redistributions of source code, in whole or part and with or without
+modification (the "Code"), must display this GPG-signed
+text in verifiable form.
+2. Redistributions of the Code in binary form must be accompanied by
+this GPG-signed text in any documentation and, each time the resulting
+executable program or a program dependent thereon is launched, a
+modest display (e.g., splash screen or banner text) of the Shabda Raaj's
+attribution information, which includes:
+(a) Name ("Shabda Raaj"),
+(b) Identification ("Usware Technologies"), and
+(c) URL ("http://uswaretech.com").
+3. Neither the name nor any trademark of the Shabda Raaj may be used to
+endorse or promote products derived from this software without specific
+prior written permission.
+4. Users are entirely responsible, to the exclusion of the Shabda Raaj and
+any other persons, for compliance with (1) regulations set by owners or
+administrators of employed equipment, (2) licensing terms of any other
+software, and (3) local regulations regarding use, including those
+regarding import, export, and use of encryption software.
+
+THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+This work builds upon the work of many others. No ownership of their
+work is claimed or implied. They retain the ownership of their work,
+included here for convenience. On being bought to my notice, mentions
+would be gratefully provided.
No changes.
No changes.
@@ -0,0 +1,4 @@
+from django.db import models
+
+class Comment(models.Model):
+ comment = models.TextField()
@@ -0,0 +1,31 @@
+{% extends 'base.html' %}
+
+{% block main_content %}
+
+Enter Comment
+
+{% if user.is_authenticated %}
+
+<p>You are currently logged in as <strong>{{ user.username }}</strong></p>
+
+<form action="." method="post">
+ {{ form }}
+ <input type="submit" name="comment_submit" value="Comment" />
+</form>
+<a href="{% url socialauth_social_logout %}">Logout</a>
+{% else %}
+
+<a href="{% url socialauth_login_page %}">Login</a>
+
+{% endif %}
+
+
+{% for comment in comments %}
+
+<p>
+ {{ comment.comment }}
+</p>
+
+{% endfor %}
+
+{% endblock %}
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
No changes.
@@ -0,0 +1,22 @@
+from django.contrib.auth.decorators import login_required
+from django.http import HttpResponseRedirect
+from commentor.models import Comment
+from django.template import RequestContext
+from django import forms
+from django.shortcuts import render_to_response
+
+@login_required
+def leave_comment(request):
+ form = CommentForm()
+ if request.POST:
+ form = CommentForm(data = request.POST)
+ if form.is_valid():
+ form.save()
+ return HttpResponseRedirect('.')
+
+ payload = {'form':form, 'comments':Comment.objects.all()}
+ return render_to_response('commentor/index.html', payload, RequestContext(request))
+
+class CommentForm(forms.ModelForm):
+ class Meta:
+ model = Comment
@@ -0,0 +1,17 @@
+This is an example app using socialauth as authentication backend
+We use modified django comments app to allow users to login via socialauth and post comments
+
+To use this app in your project:
+
+1. Copy example and example_comments dirs to your project dir
+2. Add
+ 'example',
+ 'example_comments',
+ to your INSTALLED_APPS
+3. Add
+ (r'^comments/post/', 'example_comments.views.post_comment'),
+ (r'comments/', include('django.contrib.comments.urls')),
+ to your urlpatterns
+4. Add
+ COMMENTS_APP = 'example_comments'
+ to your settings
No changes.
@@ -0,0 +1,5 @@
+from models import Post
+from django.contrib import admin
+
+admin.site.register(Post)
+
@@ -0,0 +1,12 @@
+from django.db import models
+from django.contrib.auth.models import User
+# Create your models here.
+
+class Post(models.Model):
+ author = models.ForeignKey(User)
+ date = models.DateTimeField()
+ title = models.CharField(max_length=100)
+ post = models.TextField()
+
+ def __unicode__(self):
+ return self.title
@@ -0,0 +1,22 @@
+{% load comments i18n %}
+
+<form action="{% comment_form_target %}" method="post">{% csrf_token %}
+ {% if next %}<input type="hidden" name="next" value="{{ next }}" />{% endif %}
+ {% for field in form %}
+ {% if field.is_hidden %}
+ {{ field }}
+ {% else %}
+ {% if field.errors %}{{ field.errors }}{% endif %}
+ <p
+ {% if field.errors %} class="error"{% endif %}
+ {% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
+ {{ field.label_tag }} {{ field }}
+ </p>
+ {% endif %}
+ {% endfor %}
+ <input type="hidden" name="next" id="next" value="{{request.path}}">
+ <p class="submit">
+ <input type="submit" name="post" class="submit-post" value="{% trans "Post" %}" />
+ <input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
+ </p>
+</form>
@@ -0,0 +1,10 @@
+<dl id="comments">
+ {% for comment in comment_list %}
+ <dd>
+ <p>{{ comment.comment }}</p>
+ </dd>
+ <dt id="c{{ comment.id }}">
+ on {{ comment.submit_date|date }} at {{ comment.submit_date|time }} by {{ comment.name }}
+ </dt>
+ {% endfor %}
+</dl>
@@ -0,0 +1,19 @@
+{% load comments socialauth_tags %}
+
+<h2> {{ post }}</h2>
+<p>{{ post.post }}</p>
+ <br />
+ posted by {{ post.author }} on {{ post.date|date }} at {{ post.date|time }}
+ <br />
+ <br />
+ Comments:
+ <br />
+ {% render_comment_list for post %}
+ <br />
+ {% if request.user.username %}
+ Comment as {% get_calculated_username request.user %}
+ (<a href="{% url socialauth_social_logout %}?next={{ request.path }}">Not {% get_calculated_username request.user %}?</a>)
+ {% render_comment_form for post %}
+ {% else %}
+ <a href='{% url socialauth_login_page %}?next={{ request.path }}'>Login to comment</a>
+ {% endif %}
@@ -0,0 +1,16 @@
+{% load comments %}
+{{ latest }}
+{% if object_list %}
+ {% for post in object_list %}
+ <h2>{{ post }}</h2>
+ <p>{{ post.post }}</p>
+ {% get_comment_count for post as comment_count %}
+ <b>{{ post.author }}</b> wrote {{ post.post|wordcount }} words on {{ post.date|date }} at {{ post.date|time }}
+ <br />
+ <a href='{{ post.id }}'>
+ {{ comment_count }} comments
+ </a>
+ {% endfor %}
+{% else %}
+ <a href="/admin/example/post/add/">Add a new blog post</a>
+{% endif %}
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
@@ -0,0 +1,9 @@
+from django.conf.urls.defaults import *
+from models import Post
+
+urlpatterns = patterns('',
+ url(r'^(?P<post_id>\d+)$', 'example.views.post_detail'),
+ url(r'^$', 'django.views.generic.list_detail.object_list',
+ { 'queryset' : Post.objects.all() }
+ ),
+)
@@ -0,0 +1,15 @@
+# Create your views here.
+from django.shortcuts import render_to_response, get_object_or_404
+from django.http import HttpResponseRedirect
+from django.contrib.comments.models import Comment
+from models import Post
+from django.template import RequestContext
+
+def comment_posted(request):
+ comment_id = request.GET['c']
+ post_id = Comment.objects.get(id=comment_id).content_object.id
+ return HttpResponseRedirect('/blog/'+str(post_id))
+
+def post_detail(request, post_id):
+ post = get_object_or_404(Post, pk=post_id)
+ return render_to_response('example/post_detail.html', {'post': post}, context_instance=RequestContext(request))
@@ -0,0 +1,12 @@
+from django import forms
+from django.utils.translation import ugettext_lazy as _
+from django.contrib.comments.forms import CommentDetailsForm
+
+class CommentForm(CommentDetailsForm):
+ name = forms.CharField(widget=forms.HiddenInput, required=False)
+ email = forms.EmailField(widget=forms.HiddenInput, required=False)
+ url = forms.URLField(widget=forms.HiddenInput, required=False)
+
+
+def get_form():
+ return CommentForm
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
@@ -0,0 +1,23 @@
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
@@ -0,0 +1,8 @@
+# Create your views here.
+
+from django.contrib.auth.decorators import login_required
+from django.contrib.comments.views.comments import post_comment as old_post_comment
+
+@login_required
+def post_comment(request):
+ return old_post_comment(request)
Oops, something went wrong.

0 comments on commit 8f8dd2c

Please sign in to comment.