Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[djangoproject.com] Added a foundation contact form.

git-svn-id: http://code.djangoproject.com/svn/djangoproject.com@7895 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d25f02856b83c9f4ee7756c8cc0f4cf9b3733f89 1 parent 124385b
authored July 11, 2008
0  django_website/apps/contact/__init__.py
No changes.
17  django_website/apps/contact/forms.py
... ...
@@ -0,0 +1,17 @@
  1
+import textwrap
  2
+from django import newforms as forms
  3
+from contact_form.forms import AkismetContactForm
  4
+
  5
+attrs = {'class': 'required'}
  6
+
  7
+class BaseContactForm(AkismetContactForm):
  8
+    message_subject = forms.CharField(max_length=100, widget=forms.TextInput(attrs=attrs), label=u'Message subject')
  9
+
  10
+    def subject(self):
  11
+        return "[Contact form] " + self.cleaned_data["message_subject"]
  12
+
  13
+    def message(self):
  14
+        return textwrap.wrap(self.cleaned_data["body"], 76)
  15
+
  16
+class FoundationContactForm(BaseContactForm):
  17
+    pass
24  django_website/apps/contact/urls.py
... ...
@@ -0,0 +1,24 @@
  1
+from django.conf.urls.defaults import *
  2
+from django.views.generic.simple import direct_to_template
  3
+from contact_form.views import contact_form
  4
+from django_website.apps.contact.forms import FoundationContactForm
  5
+
  6
+urlpatterns = patterns('',
  7
+    url(
  8
+        regex = r'^foundation/$',
  9
+        view  = contact_form,
  10
+        kwargs = dict(
  11
+            form_class = FoundationContactForm,
  12
+            template_name = 'contact/foundation.html',
  13
+        ),
  14
+        name = 'contact_foundation',
  15
+    ),
  16
+    url(
  17
+        regex = r'^sent/',
  18
+        view  = direct_to_template,
  19
+        kwargs = dict(
  20
+            template = 'contact/sent.html',
  21
+        ),
  22
+        name = 'contact_sent',
  23
+    )
  24
+)
18  django_website/apps/docs/views.py
@@ -11,9 +11,11 @@
11 11
 from django_website.apps.docs import builder
12 12
 import pysvn
13 13
 
  14
+REVISION = pysvn.Revision(pysvn.opt_revision_kind.head)
  15
+
14 16
 def doc_index(request, version=None):
15 17
     client, version, docroot = _get_svnroot(version, "docs/")
16  
-    doclist = client.ls(docroot, recurse=False)
  18
+    doclist = client.ls(docroot, recurse=False, revision=REVISION)
17 19
     
18 20
     # Convert list of URLs to list of document slugs.
19 21
     doclist = [os.path.splitext(os.path.basename(doc.name))[0] for doc in doclist]
@@ -30,14 +32,14 @@ def doc_detail(request, slug, version=None):
30 32
 
31 33
     docpath = urlparse.urljoin(docroot, slug+".txt")
32 34
     try:
33  
-        name, info = client.info2(docpath)[0]
  35
+        name, info = client.info2(docpath, revision=REVISION)[0]
34 36
     except pysvn.ClientError:
35 37
         raise Http404("Invalid doc: %r (version %r)" % (slug, version))
36 38
         
37 39
     cache_key = "djangowebsite:docs:%s:%s:%s" % (version, slug, info.rev.number)
38 40
     parts = cache.get(cache_key)
39 41
     if parts is None:
40  
-        parts = builder.build_document(client.cat(docpath))
  42
+        parts = builder.build_document(client.cat(docpath, revision=REVISION))
41 43
         cache.set(cache_key, parts, 60*60)
42 44
     
43 45
     template_list = ["docs/%s_detail.html" % version, "docs/detail.html"]
@@ -57,9 +59,9 @@ def model_index(request, version=None):
57 59
     cache_key = "djangowebsite:docs:modelindex:%s" % version
58 60
     model_docs = cache.get(cache_key, [])
59 61
     if not model_docs:
60  
-        for testdir in client.ls(testroot):
  62
+        for testdir in client.ls(testroot, revision=REVISION):
61 63
             try:
62  
-                content = client.cat(os.path.join(testdir.name, "models.py"))
  64
+                content = client.cat(os.path.join(testdir.name, "models.py"), revision=REVISION)
63 65
             except pysvn.ClientError:
64 66
                 continue
65 67
 
@@ -87,12 +89,12 @@ def model_index(request, version=None):
87 89
     
88 90
 def model_detail(request, slug, version=None):
89 91
     client, version, modelfile = _get_svnroot(version, "tests/modeltests/%s/models.py" % slug)
90  
-    name, info = client.info2(modelfile)[0]
  92
+    name, info = client.info2(modelfile, revision=REVISION)[0]
91 93
     
92 94
     cache_key = "djangowebsite:docs:model:%s:%s:%s" % (version, slug, info.rev.number)
93 95
     parts = cache.get(cache_key)
94 96
     if parts is None:
95  
-        parts = builder.build_model_document(client.cat(modelfile))
  97
+        parts = builder.build_model_document(client.cat(modelfile, revision=REVISION))
96 98
         cache.set(cache_key, parts, 60*60)
97 99
         
98 100
     return render_to_response(
@@ -112,7 +114,7 @@ def _get_svnroot(version, subpath):
112 114
     docroot = urlparse.urljoin(settings.DJANGO_SVN_ROOT, subpath)
113 115
 
114 116
     try:
115  
-        client.info2(docroot, recurse=False)
  117
+        client.info2(docroot, recurse=False, revision=REVISION)
116 118
     except pysvn.ClientError:
117 119
         raise Http404("Bad SVN path: %s" % docroot)
118 120
         
4  django_website/settings.py
@@ -3,7 +3,7 @@
3 3
 # Far too clever trick to know if we're running on the deployment server.
4 4
 DEVELOPMENT_MODE = (platform.node() != "djangoproject")
5 5
 
6  
-ADMINS = (('Adrian Holovaty','holovaty@gmail.com'), ('Jacob Kaplan-Moss', 'jacob@lawrence.com'))
  6
+ADMINS = (('Adrian Holovaty','holovaty@gmail.com'), ('Jacob Kaplan-Moss', 'jacob@jacobian.org'))
7 7
 TIME_ZONE = 'America/Chicago'
8 8
 
9 9
 SERVER_EMAIL = 'root@pam.servers.ljworld.com'
@@ -16,7 +16,7 @@
16 16
 if DEVELOPMENT_MODE:
17 17
     DEBUG = True
18 18
     PREPEND_WWW = False
19  
-    CACHE_BACKEND = "file:///tmp/djangoprojectcache/"
  19
+    CACHE_BACKEND = "dummy:///"
20 20
     DJANGO_SVN_ROOT = "http://code.djangoproject.com/svn/django/"
21 21
 else:
22 22
     DEBUG = False
45  django_website/templates/base_foundation.html
... ...
@@ -0,0 +1,45 @@
  1
+{% extends "base_community.html" %}
  2
+
  3
+{% block content-related %}
  4
+<h2>Support Django</h2>
  5
+<script type="text/javascript"> 
  6
+function validateAmount(amount){
  7
+	if(amount.value.match( /^[0-9]+(\.([0-9]+))?$/)){
  8
+		return true;
  9
+	}else{
  10
+		alert('You must enter a valid donation.');
  11
+		amount.focus();
  12
+		return false;
  13
+	}
  14
+}
  15
+</script>
  16
+<form action="https://checkout.google.com/cws/v2/Donations/404630304217012/checkoutForm" id="BB_BuyButtonForm" method="post" name="BB_BuyButtonForm" onSubmit="return validateAmount(this.item_price_1)">
  17
+    <input name="item_name_1" type="hidden" value="Support the Django Software Foundation!"/>
  18
+    <input name="item_description_1" type="hidden" value="Thanks for your help! Your money will directly support the development of Django by sponsoring developer meetings, user conferences, and other community activities."/>
  19
+    <input name="item_quantity_1" type="hidden" value="1"/>
  20
+    <input name="item_currency_1" type="hidden" value="USD"/>
  21
+    <input name="item_is_modifiable_1" type="hidden" value="true"/>
  22
+    <input name="item_min_price_1" type="hidden" value="0.0"/>
  23
+    <input name="item_max_price_1" type="hidden" value="25000.0"/>
  24
+    <input name="_charset_" type="hidden" value="utf-8"/>
  25
+    <input id="item_price_1" name="item_price_1" onfocus="this.style.color='black'; this.value='';" size="6" type="text" value="20.00"/>
  26
+    <input type="submit" name="submit" value="Donate" id="submit">
  27
+</form>
  28
+
  29
+<h3>Questions?</h3>
  30
+<p>Read more about <a href="/foundation/donate/">donating to the DSF</a>.
  31
+  
  32
+<h2>Licensing &amp; Trademarks</h2>  
  33
+<ul>
  34
+  <li>Django licensing policies</li>
  35
+  <li>Contributor license agreements</li>
  36
+</ul>
  37
+
  38
+<h2>About the foundation</h2>
  39
+<ul>
  40
+  <li>FAQ</li>
  41
+  <li>Records</li>
  42
+  <li>Board meeting minutes</li>
  43
+  <li>Board resolutions</li>
  44
+</ul>
  45
+{% endblock %}
45  django_website/templates/contact/foundation.html
... ...
@@ -0,0 +1,45 @@
  1
+{% extends "base_foundation.html" %}
  2
+
  3
+{% block title %}Contact the Django Software Foundation{% endblock %}
  4
+
  5
+{% block extrahead %}
  6
+  {{ block.super }}
  7
+  <style type="text/css" media="screen">
  8
+    form.contact label { display: block; font-weight: bold; margin-top: 1.5em; margin-bottom: 0;}
  9
+    form.contact label span { font-weight: normal; color: #555; }
  10
+    form.contact input, 
  11
+    form.contact textarea, 
  12
+    form.contact select { width: 99%; padding: 1px; }
  13
+    form.contact p { margin: 0; }
  14
+    form.contact p.submit { text-align: right; margin-top: 1em; margin-right: 0;}
  15
+    form.contact p.submit input { width: 10em; font-size: 1.5em; }
  16
+    form.contact p.errors { margin: 0; padding: 0; font-weight: bold; color: red; }
  17
+  </style>
  18
+{% endblock %}
  19
+
  20
+{% block content %}
  21
+<h1>Contact the Django Software Foundation</h1>
  22
+<form action="." method="post" accept-charset="utf-8" class="contact">
  23
+  <p>
  24
+    <label for="id_name">Your name:</label>
  25
+    {% if form.name.errors %}<p class="errors">{{ form.name.errors.as_text }}</p>{% endif %}
  26
+    {{ form.name }}
  27
+  </p>
  28
+  <p>
  29
+    <label for="id_email">Your email address:</label>
  30
+    {% if form.email.errors %}<p class="errors">{{ form.email.errors.as_text }}</p>{% endif %}
  31
+    {{ form.email }}
  32
+  </p>
  33
+  <p>
  34
+    <label for="id_message_subject">Message subject:</label>
  35
+    {% if form.message_subject.errors %}<p class="errors">{{ form.message_subject.errors.as_text }}</p>{% endif %}
  36
+    {{ form.message_subject }}
  37
+  </p>
  38
+  <p>
  39
+    <label for="id_body">Your message:</label>
  40
+    {% if form.body.errors %}<p class="errors">{{ form.body.errors.as_text }}</p>{% endif %}
  41
+    {{ form.body }}
  42
+  </p>
  43
+  <p class="submit"><input type="submit" value="Send &rarr;"></p>
  44
+</form>
  45
+{% endblock %}
18  django_website/templates/contact/sent.html
... ...
@@ -0,0 +1,18 @@
  1
+{% extends "base.html" %}
  2
+
  3
+{% block title %}Message sent{% endblock %}
  4
+
  5
+{% block content %}
  6
+  <h1>Message sent</h1>
  7
+  <h2 class="deck">Your message has been sent; thanks!</h2>
  8
+  <p>
  9
+    Your mail <em>will</em> be read by a real, live human being. We can't
  10
+    guarantee when or whether you'll get a reply, but your message
  11
+    <em>will</em> be read, generally within the next couple of days.
  12
+  </p>
  13
+  <p>
  14
+    If you're expecting a reply and don't get one, please feel free
  15
+    to send a reminder. Please wait a few days, however, unless
  16
+    it's an emergency.
  17
+  </p>
  18
+{% endblock %}
22  django_website/templates/flatpages/foundation.html
... ...
@@ -1,10 +1,22 @@
1  
-{% extends "base_community.html" %}
  1
+{% extends "base_foundation.html" %}
2 2
 
3  
-{% block title %}Foundation{% endblock %}
  3
+{% block extrahead %}
  4
+<style type="text/css" media="screen">
  5
+  form #submit { 
  6
+      border: 0px none; 
  7
+      background-color: transparent;
  8
+      color: transparent;
  9
+      background-image: url(https://checkout.google.com/buttons/donateNow.gif?merchant_id=404630304217012&w=115&h=50&style=trans&variant=text&loc=en_US);
  10
+      background-position: 0px 3px;
  11
+      width: 115px;
  12
+      height: 35px;
  13
+  }
  14
+</style>
  15
+{% endblock %}
  16
+
  17
+{% block title %}{{ flatpage.title }}{% endblock %}
4 18
 
5 19
 {% block content %}
6 20
 <h1>{{ flatpage.title }}</h1>
7 21
 {{ flatpage.content }}
8  
-{% endblock %}
9  
-
10  
-{% block content-related %}{% endblock %}
  22
+{% endblock %}
1  django_website/urls.py
@@ -36,6 +36,7 @@
36 36
     (r'^comments/$', 'django.views.generic.list_detail.object_list', comments_info_dict),
37 37
     (r'^comments/', include('django.contrib.comments.urls.comments')),
38 38
     (r'^community/$', 'django.views.generic.list_detail.object_list', aggregator_info_dict),
  39
+    (r'^contact/', include('django_website.apps.contact.urls')),
39 40
     (r'^documentation/', include('django_website.apps.docs.urls')),
40 41
     (r'^r/', include('django.conf.urls.shortcut')),
41 42
     (r'^rss/(?P<url>.*)/$', 'django.contrib.syndication.views.feed', {'feed_dict': feeds}),

0 notes on commit d25f028

Please sign in to comment.
Something went wrong with that request. Please try again.