Permalink
Browse files

Initial Pinax project start

  • Loading branch information...
0 parents commit 01417605c5ae107d98b48b216c8aed9250e47df1 @lmorchard committed Jul 13, 2010
Showing with 21,688 additions and 0 deletions.
  1. +7 −0 .gitignore
  2. +9 −0 __init__.py
  3. 0 apps/__init__.py
  4. 0 apps/about/__init__.py
  5. +3 −0 apps/about/models.py
  6. +14 −0 apps/about/urls.py
  7. +1 −0 apps/about/views.py
  8. 0 apps/friends_app/__init__.py
  9. +14 −0 apps/friends_app/context_processors.py
  10. +18 −0 apps/friends_app/forms.py
  11. +3 −0 apps/friends_app/models.py
  12. +10 −0 apps/friends_app/urls.py
  13. +171 −0 apps/friends_app/views.py
  14. +55 −0 context_processors.py
  15. 0 deploy/__init__.py
  16. +35 −0 deploy/modpython.py
  17. BIN locale/ar/LC_MESSAGES/django.mo
  18. +358 −0 locale/ar/LC_MESSAGES/django.po
  19. BIN locale/bg/LC_MESSAGES/django.mo
  20. +355 −0 locale/bg/LC_MESSAGES/django.po
  21. BIN locale/bn/LC_MESSAGES/django.mo
  22. +355 −0 locale/bn/LC_MESSAGES/django.po
  23. BIN locale/bs/LC_MESSAGES/django.mo
  24. +355 −0 locale/bs/LC_MESSAGES/django.po
  25. BIN locale/ca/LC_MESSAGES/django.mo
  26. +356 −0 locale/ca/LC_MESSAGES/django.po
  27. BIN locale/cs/LC_MESSAGES/django.mo
  28. +356 −0 locale/cs/LC_MESSAGES/django.po
  29. BIN locale/cy/LC_MESSAGES/django.mo
  30. +355 −0 locale/cy/LC_MESSAGES/django.po
  31. BIN locale/da/LC_MESSAGES/django.mo
  32. +355 −0 locale/da/LC_MESSAGES/django.po
  33. BIN locale/de/LC_MESSAGES/django.mo
  34. +356 −0 locale/de/LC_MESSAGES/django.po
  35. BIN locale/el/LC_MESSAGES/django.mo
  36. +356 −0 locale/el/LC_MESSAGES/django.po
  37. BIN locale/en/LC_MESSAGES/django.mo
  38. +355 −0 locale/en/LC_MESSAGES/django.po
  39. BIN locale/es/LC_MESSAGES/django.mo
  40. +356 −0 locale/es/LC_MESSAGES/django.po
  41. BIN locale/es_AR/LC_MESSAGES/django.mo
  42. +356 −0 locale/es_AR/LC_MESSAGES/django.po
  43. BIN locale/et/LC_MESSAGES/django.mo
  44. +355 −0 locale/et/LC_MESSAGES/django.po
  45. BIN locale/eu/LC_MESSAGES/django.mo
  46. +355 −0 locale/eu/LC_MESSAGES/django.po
  47. BIN locale/fa/LC_MESSAGES/django.mo
  48. +355 −0 locale/fa/LC_MESSAGES/django.po
  49. BIN locale/fi/LC_MESSAGES/django.mo
  50. +356 −0 locale/fi/LC_MESSAGES/django.po
  51. BIN locale/fr/LC_MESSAGES/django.mo
  52. +375 −0 locale/fr/LC_MESSAGES/django.po
  53. BIN locale/fy_NL/LC_MESSAGES/django.mo
  54. +355 −0 locale/fy_NL/LC_MESSAGES/django.po
  55. BIN locale/ga/LC_MESSAGES/django.mo
  56. +357 −0 locale/ga/LC_MESSAGES/django.po
  57. BIN locale/gl/LC_MESSAGES/django.mo
  58. +355 −0 locale/gl/LC_MESSAGES/django.po
  59. BIN locale/he/LC_MESSAGES/django.mo
  60. +356 −0 locale/he/LC_MESSAGES/django.po
  61. BIN locale/hi/LC_MESSAGES/django.mo
  62. +355 −0 locale/hi/LC_MESSAGES/django.po
  63. BIN locale/hr/LC_MESSAGES/django.mo
  64. +357 −0 locale/hr/LC_MESSAGES/django.po
  65. BIN locale/hu/LC_MESSAGES/django.mo
  66. +356 −0 locale/hu/LC_MESSAGES/django.po
  67. BIN locale/is/LC_MESSAGES/django.mo
  68. +356 −0 locale/is/LC_MESSAGES/django.po
  69. BIN locale/it/LC_MESSAGES/django.mo
  70. +356 −0 locale/it/LC_MESSAGES/django.po
  71. BIN locale/ja/LC_MESSAGES/django.mo
  72. +356 −0 locale/ja/LC_MESSAGES/django.po
  73. BIN locale/ka/LC_MESSAGES/django.mo
  74. +355 −0 locale/ka/LC_MESSAGES/django.po
  75. BIN locale/km/LC_MESSAGES/django.mo
  76. +356 −0 locale/km/LC_MESSAGES/django.po
  77. BIN locale/kn/LC_MESSAGES/django.mo
  78. +355 −0 locale/kn/LC_MESSAGES/django.po
  79. BIN locale/ko/LC_MESSAGES/django.mo
  80. +355 −0 locale/ko/LC_MESSAGES/django.po
  81. BIN locale/lt/LC_MESSAGES/django.mo
  82. +355 −0 locale/lt/LC_MESSAGES/django.po
  83. BIN locale/lv/LC_MESSAGES/django.mo
  84. +355 −0 locale/lv/LC_MESSAGES/django.po
  85. BIN locale/mk/LC_MESSAGES/django.mo
  86. +356 −0 locale/mk/LC_MESSAGES/django.po
  87. BIN locale/nl/LC_MESSAGES/django.mo
  88. +356 −0 locale/nl/LC_MESSAGES/django.po
  89. BIN locale/no/LC_MESSAGES/django.mo
  90. +355 −0 locale/no/LC_MESSAGES/django.po
  91. BIN locale/pl/LC_MESSAGES/django.mo
  92. +357 −0 locale/pl/LC_MESSAGES/django.po
  93. BIN locale/pt/LC_MESSAGES/django.mo
  94. +355 −0 locale/pt/LC_MESSAGES/django.po
  95. BIN locale/pt_BR/LC_MESSAGES/django.mo
  96. +356 −0 locale/pt_BR/LC_MESSAGES/django.po
  97. BIN locale/ro/LC_MESSAGES/django.mo
  98. +356 −0 locale/ro/LC_MESSAGES/django.po
  99. BIN locale/ru/LC_MESSAGES/django.mo
  100. +356 −0 locale/ru/LC_MESSAGES/django.po
  101. BIN locale/sk/LC_MESSAGES/django.mo
  102. +356 −0 locale/sk/LC_MESSAGES/django.po
  103. BIN locale/sl/LC_MESSAGES/django.mo
  104. +356 −0 locale/sl/LC_MESSAGES/django.po
  105. BIN locale/sq/LC_MESSAGES/django.mo
  106. +355 −0 locale/sq/LC_MESSAGES/django.po
  107. BIN locale/sr/LC_MESSAGES/django.mo
  108. +357 −0 locale/sr/LC_MESSAGES/django.po
  109. BIN locale/sr_Latn/LC_MESSAGES/django.mo
  110. +357 −0 locale/sr_Latn/LC_MESSAGES/django.po
  111. BIN locale/sv/LC_MESSAGES/django.mo
  112. +356 −0 locale/sv/LC_MESSAGES/django.po
  113. BIN locale/ta/LC_MESSAGES/django.mo
  114. +417 −0 locale/ta/LC_MESSAGES/django.po
  115. BIN locale/te/LC_MESSAGES/django.mo
  116. +356 −0 locale/te/LC_MESSAGES/django.po
  117. BIN locale/th/LC_MESSAGES/django.mo
  118. +356 −0 locale/th/LC_MESSAGES/django.po
  119. BIN locale/tr/LC_MESSAGES/django.mo
  120. +356 −0 locale/tr/LC_MESSAGES/django.po
  121. BIN locale/uk/LC_MESSAGES/django.mo
  122. +355 −0 locale/uk/LC_MESSAGES/django.po
  123. BIN locale/vi/LC_MESSAGES/django.mo
  124. +356 −0 locale/vi/LC_MESSAGES/django.po
  125. BIN locale/zh_CN/LC_MESSAGES/django.mo
  126. +356 −0 locale/zh_CN/LC_MESSAGES/django.po
  127. BIN locale/zh_TW/LC_MESSAGES/django.mo
  128. +356 −0 locale/zh_TW/LC_MESSAGES/django.po
  129. +27 −0 manage.py
  130. +31 −0 media/css/site_tabs.css
  131. +65 −0 requirements/base.txt
  132. +7 −0 requirements/project.txt
  133. +292 −0 settings.py
  134. +52 −0 templates/about/what_next.html
  135. +28 −0 templates/account/base.html
  136. +43 −0 templates/account/other_services.html
  137. +90 −0 templates/friends_app/contacts.html
  138. +107 −0 templates/friends_app/invitations.html
  139. +15 −0 templates/friends_app/invite.html
  140. +5 −0 templates/friends_app/invite_facebox.html
  141. +24 −0 templates/friends_app/invite_form.html
  142. +59 −0 templates/homepage.html
  143. +1 −0 templates/notification/base.html
  144. +22 −0 templates/notification/single.html
  145. +26 −0 templates/photos/base.html
  146. +80 −0 templates/site_base.html
  147. +127 −0 templates/tags/index.html
  148. 0 tests/__init__.py
  149. +10 −0 tests/model_coverage.py
  150. +36 −0 tests/smoke_test.py
  151. +42 −0 tests/test_notification_templates.py
  152. +157 −0 urls.py
@@ -0,0 +1,7 @@
+tmp/
+src/
+pip-log.txt
+settings_local.py
+*.pyc
+*.swp
+*.db
@@ -0,0 +1,9 @@
+# -*- coding: utf-8 -*-
+
+__about__ = """
+This project demonstrates a social networking site. It provides profiles,
+friends, photos, blogs, tribes, wikis, tweets, bookmarks, swaps,
+locations and user-to-user messaging.
+
+In 0.5 this was called "complete_project".
+"""
No changes.
No changes.
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
@@ -0,0 +1,14 @@
+from django.conf.urls.defaults import *
+from django.views.generic.simple import direct_to_template
+
+
+
+urlpatterns = patterns("",
+ url(r"^$", direct_to_template, {"template": "about/about.html"}, name="about"),
+
+ url(r"^terms/$", direct_to_template, {"template": "about/terms.html"}, name="terms"),
+ url(r"^privacy/$", direct_to_template, {"template": "about/privacy.html"}, name="privacy"),
+ url(r"^dmca/$", direct_to_template, {"template": "about/dmca.html"}, name="dmca"),
+
+ url(r"^what_next/$", direct_to_template, {"template": "about/what_next.html"}, name="what_next"),
+)
@@ -0,0 +1 @@
+# Create your views here.
No changes.
@@ -0,0 +1,14 @@
+from friends.models import FriendshipInvitation
+
+
+
+def invitations(request):
+ if request.user.is_authenticated():
+ return {
+ "invitations_count": FriendshipInvitation.objects.filter(
+ to_user = request.user,
+ status = "2"
+ ).count()
+ }
+ else:
+ return {}
@@ -0,0 +1,18 @@
+from django import forms
+
+from django.contrib.auth.models import User
+
+from friends.models import *
+from friends.importer import import_vcards
+
+
+
+# @@@ move to django-friends when ready
+
+class ImportVCardForm(forms.Form):
+
+ vcard_file = forms.FileField(label="vCard File")
+
+ def save(self, user):
+ imported, total = import_vcards(self.cleaned_data["vcard_file"].content, user)
+ return imported, total
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
@@ -0,0 +1,10 @@
+from django.conf.urls.defaults import *
+
+
+
+urlpatterns = patterns("",
+ url(r"^$", "friends_app.views.friends", name="invitations"),
+ url(r"^contacts/$", "friends_app.views.contacts", name="invitations_contacts"),
+ url(r"^accept/(\w+)/$", "friends_app.views.accept_join", name="friends_accept_join"),
+ url(r"^invite/$", "friends_app.views.invite", name="invite_to_join"),
+)
@@ -0,0 +1,171 @@
+from django.conf import settings
+from django.http import HttpResponseRedirect
+from django.shortcuts import get_object_or_404, render_to_response
+from django.template import RequestContext
+
+from django.contrib import messages
+from django.contrib.auth.decorators import login_required
+
+from django.utils.translation import ugettext, ugettext_lazy as _
+
+from friends.forms import JoinRequestForm
+from friends.importer import import_yahoo, import_google
+from friends.models import *
+
+from pinax.apps.account.forms import SignupForm
+
+from friends_app.forms import ImportVCardForm
+
+
+
+# @@@ if made more generic these could be moved to django-friends proper
+
+@login_required
+def friends(request, template_name="friends_app/invitations.html"):
+ if request.method == "POST":
+ invitation_id = request.POST.get("invitation", None)
+ if request.POST["action"] == "accept":
+ try:
+ invitation = FriendshipInvitation.objects.get(id=invitation_id)
+ if invitation.to_user == request.user:
+ invitation.accept()
+ messages.add_message(request, messages.SUCCESS,
+ ugettext("Accepted friendship request from %(from_user)s") % {
+ "from_user": invitation.from_user
+ }
+ )
+ except FriendshipInvitation.DoesNotExist:
+ pass
+ elif request.POST["action"] == "decline":
+ try:
+ invitation = FriendshipInvitation.objects.get(id=invitation_id)
+ if invitation.to_user == request.user:
+ invitation.decline()
+ messages.add_message(request, messages.SUCCESS,
+ ugettext("Declined friendship request from %(from_user)s") % {
+ "from_user": invitation.from_user
+ }
+ )
+ except FriendshipInvitation.DoesNotExist:
+ pass
+
+ invites_received = request.user.invitations_to.invitations().order_by("-sent")
+ invites_sent = request.user.invitations_from.invitations().order_by("-sent")
+ joins_sent = request.user.join_from.all().order_by("-sent")
+
+ return render_to_response(template_name, {
+ "invites_received": invites_received,
+ "invites_sent": invites_sent,
+ "joins_sent": joins_sent,
+ }, context_instance=RequestContext(request))
+
+
+@login_required
+def invite(request, form_class=JoinRequestForm, **kwargs):
+ template_name = kwargs.get("template_name", "friends_app/invite.html")
+ if request.is_ajax():
+ template_name = kwargs.get(
+ "template_name_facebox",
+ "friends_app/invite_facebox.html"
+ )
+
+ join_request_form = form_class()
+ if request.method == "POST":
+ join_request_form = form_class(request.POST)
+ if join_request_form.is_valid():
+ join_request_form.save(request.user)
+ return HttpResponseRedirect(reverse("invitations"))
+ return render_to_response(template_name, {
+ "join_request_form": join_request_form,
+ }, context_instance=RequestContext(request))
+
+
+def accept_join(request, confirmation_key, form_class=SignupForm,
+ template_name="account/signup.html"):
+ join_invitation = get_object_or_404(JoinInvitation, confirmation_key=confirmation_key.lower())
+ if request.user.is_authenticated():
+ return render_to_response("account/signup.html", {
+ }, context_instance=RequestContext(request))
+ else:
+ form = form_class(initial={
+ "email": join_invitation.contact.email,
+ "confirmation_key": join_invitation.confirmation_key
+ })
+ return render_to_response(template_name, {
+ "form": form,
+ }, context_instance=RequestContext(request))
+
+
+@login_required
+def contacts(request, form_class=ImportVCardForm,
+ template_name="friends_app/contacts.html"):
+ if request.method == "POST":
+ if request.POST["action"] == "upload_vcard":
+ import_vcard_form = form_class(request.POST, request.FILES)
+ if import_vcard_form.is_valid():
+ imported, total = import_vcard_form.save(request.user)
+ messages.add_message(request, messages.SUCCESS,
+ ugettext("%(total)s vCards found, %(imported)s contacts imported.") % {
+ "imported": imported,
+ "total": total
+ }
+ )
+ import_vcard_form = ImportVCardForm()
+ else:
+ import_vcard_form = form_class()
+ if request.POST["action"] == "import_yahoo":
+ bbauth_token = request.session.get("bbauth_token")
+ del request.session["bbauth_token"]
+ if bbauth_token:
+ imported, total = import_yahoo(bbauth_token, request.user)
+ messages.add_message(request, message.SUCCESS,
+ ugettext("%(total)s people with email found, %(imported)s contacts imported.") % {
+ "imported": imported,
+ "total": total
+ }
+ )
+ if request.POST["action"] == "import_google":
+ authsub_token = request.session.get("authsub_token")
+ del request.session["authsub_token"]
+ if authsub_token:
+ imported, total = import_google(authsub_token, request.user)
+ messages.add_message(request, messages.SUCCESS,
+ ugettext("%(total)s people with email found, %(imported)s contacts imported.") % {
+ "imported": imported,
+ "total": total
+ }
+ )
+ else:
+ import_vcard_form = form_class()
+
+ return render_to_response(template_name, {
+ "import_vcard_form": import_vcard_form,
+ "bbauth_token": request.session.get("bbauth_token"),
+ "authsub_token": request.session.get("authsub_token"),
+ }, context_instance=RequestContext(request))
+
+
+@login_required
+def friends_objects(request, template_name, friends_objects_function, extra_context={}):
+ """
+ Display friends' objects.
+
+ This view takes a template name and a function. The function should
+ take an iterator over users and return an iterator over objects
+ belonging to those users. This iterator over objects is then passed
+ to the template of the given name as ``object_list``.
+
+ The template is also passed variable defined in ``extra_context``
+ which should be a dictionary of variable names to functions taking a
+ request object and returning the value for that variable.
+ """
+
+ friends = friend_set_for(request.user)
+
+ dictionary = {
+ "object_list": friends_objects_function(friends),
+ }
+ for name, func in extra_context.items():
+ dictionary[name] = func(request)
+
+ return render_to_response(template_name, dictionary, context_instance=RequestContext(request))
@@ -0,0 +1,55 @@
+from django.conf import settings
+from django.core.exceptions import ImproperlyConfigured
+from django.contrib.auth.models import User
+
+from microblogging.models import Tweet
+from pinax.apps.tribes.models import Tribe
+from bookmarks.models import Bookmark
+from pinax.apps.blog.models import Post
+
+_inbox_count_sources = None
+
+def inbox_count_sources():
+ global _inbox_count_sources
+ if _inbox_count_sources is None:
+ sources = []
+ for path in settings.COMBINED_INBOX_COUNT_SOURCES:
+ i = path.rfind('.')
+ module, attr = path[:i], path[i+1:]
+ try:
+ mod = __import__(module, {}, {}, [attr])
+ except ImportError, e:
+ raise ImproperlyConfigured('Error importing request processor module %s: "%s"' % (module, e))
+ try:
+ func = getattr(mod, attr)
+ except AttributeError:
+ raise ImproperlyConfigured('Module "%s" does not define a "%s" callable request processor' % (module, attr))
+ sources.append(func)
+ _inbox_count_sources = tuple(sources)
+ return _inbox_count_sources
+
+def combined_inbox_count(request):
+ """
+ A context processor that uses other context processors defined in
+ setting.COMBINED_INBOX_COUNT_SOURCES to return the combined number from
+ arbitrary counter sources.
+ """
+ count = 0
+ for func in inbox_count_sources():
+ counts = func(request)
+ if counts:
+ for value in counts.itervalues():
+ try:
+ count = count + int(value)
+ except (TypeError, ValueError):
+ pass
+ return {'combined_inbox_count': count,}
+
+def footer(request):
+ return {
+ 'latest_tweets': Tweet.objects.all().order_by('-sent')[:5],
+ 'latest_tribes': Tribe.objects.all().order_by('-created')[:5],
+ 'latest_users': User.objects.all().order_by('-date_joined')[:9],
+ 'latest_bookmarks': Bookmark.objects.all().order_by('-added')[:5],
+ 'latest_blogs': Post.objects.filter(status=2).order_by('-publish')[:5],
+ }
No changes.
@@ -0,0 +1,35 @@
+import os
+import sys
+
+from os.path import abspath, dirname, join
+from site import addsitedir
+
+# activate virtualenv
+VIRTUALENV_BASE = ""
+if not VIRTUALENV_BASE:
+ raise Exception("VIRTUALENV_BASE is not set correctly.")
+
+activate_this = join(VIRTUALENV_BASE, "bin/activate_this.py")
+execfile(activate_this, dict(__file__=activate_this))
+
+from django.core.handlers.modpython import ModPythonHandler
+
+
+
+class PinaxModPythonHandler(ModPythonHandler):
+ def __call__(self, req):
+ # mod_python fakes the environ, and thus doesn't process SetEnv.
+ # This fixes that. Django will call this again since there is no way
+ # of overriding __call__ to just process the request.
+ os.environ.update(req.subprocess_env)
+ from django.conf import settings
+
+ sys.path.insert(0, abspath(join(dirname(__file__), "../../")))
+ sys.path.insert(0, join(settings.PROJECT_ROOT, "apps"))
+
+ return super(PinaxModPythonHandler, self).__call__(req)
+
+
+def handler(req):
+ # mod_python hooks into this function.
+ return PinaxModPythonHandler()(req)
Binary file not shown.
Oops, something went wrong.

0 comments on commit 0141760

Please sign in to comment.