This repository has been archived by the owner on Jul 29, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
views.py
68 lines (49 loc) · 2.37 KB
/
views.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from django.contrib import messages
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from postmark import PMMail
from sunlightfoundation.com.forms import ContactForm
from sunlightfoundation.com.models import FeaturedPost, FeaturedTopic
from thefoundation.funding.models import Contribution
def index(request):
if 'message' in request.GET:
msg = request.GET['message']
messages.debug(request, msg)
messages.info(request, msg)
messages.success(request, msg)
messages.warning(request, msg)
messages.error(request, msg)
featured_posts = FeaturedPost.objects.filter(published=True).order_by("-date_published")[:2]
featured_topics = FeaturedTopic.objects.filter(published=True).order_by('-id')[:3]
data = {
'featured_posts': featured_posts,
'featured_topics': featured_topics,
}
return render_to_response('index.html', data, context_instance=RequestContext(request))
def funding(request):
data = {'contributions': Contribution.objects.all()}
return render_to_response('about/funding.html', data, context_instance=RequestContext(request))
def contact(request):
if request.method == "POST":
form = ContactForm(request.POST)
if form.is_valid():
name = form.cleaned_data['name']
from_email = form.cleaned_data['from_email']
message = "%s <%s> wrote:\n\n%s" % (name, from_email, form.cleaned_data['message'])
PMMail(
to='[email protected]',
reply_to="%s <%s>" % (name, from_email),
subject="[SunlightFoundation.com] message from %s" % name,
text_body=message,
).send()
messages.success(request, 'Thank you for contacting us! We will get back to you shortly.')
return HttpResponseRedirect("/contact/")
else:
form = ContactForm()
return render_to_response("contact/form.html",
{ "form": form },
context_instance=RequestContext(request))
def projects(request):
return render_to_response("projects/index.html",
context_instance=RequestContext(request))