add contact forms for people and group pages
This commit is contained in:
parent
5da5255cd4
commit
559581dd62
|
@ -424,6 +424,8 @@ class Production(ItfModel):
|
||||||
persons.extend(cast_list)
|
persons.extend(cast_list)
|
||||||
return persons
|
return persons
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_dict(self):
|
def get_dict(self):
|
||||||
rel_level1 = [obj for obj in Production.objects.filter(script=self.script)]
|
rel_level1 = [obj for obj in Production.objects.filter(script=self.script)]
|
||||||
rel_level2 = list(set(obj.production_set.all() for obj in self.script.related_scripts.all()))
|
rel_level2 = list(set(obj.production_set.all() for obj in self.script.related_scripts.all()))
|
||||||
|
|
|
@ -4,6 +4,7 @@ from forms import *
|
||||||
from django.shortcuts import render_to_response, get_object_or_404
|
from django.shortcuts import render_to_response, get_object_or_404
|
||||||
from ox.django.shortcuts import render_to_json_response
|
from ox.django.shortcuts import render_to_json_response
|
||||||
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
||||||
|
from django.core.mail import send_mail
|
||||||
from django.template import RequestContext
|
from django.template import RequestContext
|
||||||
from django.http import HttpResponse, HttpResponseRedirect
|
from django.http import HttpResponse, HttpResponseRedirect
|
||||||
from django.contrib.auth.decorators import login_required
|
from django.contrib.auth.decorators import login_required
|
||||||
|
@ -141,3 +142,43 @@ def grouppopup(request):
|
||||||
'form': form
|
'form': form
|
||||||
})
|
})
|
||||||
return render_to_response("test/popup.html", context)
|
return render_to_response("test/popup.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def contact_person(request):
|
||||||
|
frm = request.user.email
|
||||||
|
to_person = request.GET.get("to", None)
|
||||||
|
try:
|
||||||
|
to = Person.objects.get(pk=to_person)
|
||||||
|
except:
|
||||||
|
return HttpResponse("An error occurred. Please contact contact@theatreforum.in and let us know. Thanks.")
|
||||||
|
message = request.GET.get("message", None)
|
||||||
|
if not message:
|
||||||
|
return HttpResponse("Please enter a message.")
|
||||||
|
if not to.user:
|
||||||
|
return HttpResponse("Sorry, person does not have an email address associated on the site.")
|
||||||
|
else:
|
||||||
|
to_email = to.user.email
|
||||||
|
send_mail("Contact on theatreforum.in", message, frm, [to_email])
|
||||||
|
return HttpResponse("Your message has been sent, thanks.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def contact_group(request):
|
||||||
|
frm = request.user.email
|
||||||
|
to_group = request.GET.get("to", None)
|
||||||
|
try:
|
||||||
|
to = TheatreGroup.objects.get(pk=to_group)
|
||||||
|
except:
|
||||||
|
return HttpResponse("An error occurred. Please contact contact@theatreforum.in and let us know. Thanks.")
|
||||||
|
message = request.GET.get("message", None)
|
||||||
|
if not message:
|
||||||
|
return HttpResponse("Please enter a message.")
|
||||||
|
if not to.added_by:
|
||||||
|
return HttpResponse("Sorry, group does not have an email address associated on the site.")
|
||||||
|
else:
|
||||||
|
#FIXME: also get email addresses of all group admins
|
||||||
|
to_email = to.added_by.email
|
||||||
|
send_mail("Contact on theatreforum.in", message, frm, [to_email])
|
||||||
|
return HttpResponse("Your message has been sent, thanks.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,39 @@
|
||||||
<div>Gender: {{ gender }}</div>
|
<div>Gender: {{ gender }}</div>
|
||||||
|
|
||||||
<a href="" class="toggleLink">Contact</a>
|
<a href="" class="toggleLink">Contact</a>
|
||||||
<div class="toggleDiv">Some text</div>
|
<div class="toggleDiv" id="contactDiv" style="display:none;">
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<form id="contactForm" action="/contact/person" method="POST">
|
||||||
|
<!-- <input type="hidden" id="contactFrom" value="{{ request.user.id }}" /> -->
|
||||||
|
<input type="hidden" id="contactTo" value="{{ obj.id }}" />
|
||||||
|
<textarea id="contactMessage" placeholder="Type your message here..."></textarea>
|
||||||
|
<input type="submit" value="Submit" />
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
You need to be signed in to contact people.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
$('.toggleLink').click(function() {
|
||||||
|
$(this).next().toggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#contactForm').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var url = $(this).attr("action");
|
||||||
|
$.get(url, {
|
||||||
|
// 'from': $('#contactFrom').val(),
|
||||||
|
'to': $('#contactTo').val(),
|
||||||
|
'message': $('#contactMessage').val()
|
||||||
|
}, function(response) {
|
||||||
|
$('#contactDiv').text(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<div class="borderYellow"><br /></div>
|
<div class="borderYellow"><br /></div>
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,41 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="borderYellow">
|
<div class="borderYellow">
|
||||||
<a href="">Contact</a>
|
<a href="" class="toggleLink">Contact</a>
|
||||||
|
<div class="toggleDiv" id="contactDiv" style="display:none;">
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<form id="contactForm" action="/contact/group" method="POST">
|
||||||
|
<!-- <input type="hidden" id="contactFrom" value="{{ request.user.id }}" /> -->
|
||||||
|
<input type="hidden" id="contactTo" value="{{ obj.id }}" />
|
||||||
|
<textarea id="contactMessage" placeholder="Type your message here..."></textarea>
|
||||||
|
<input type="submit" value="Submit" />
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
You need to be signed in to contact people.
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
$(function() {
|
||||||
|
$('.toggleLink').click(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
$(this).next().toggle();
|
||||||
|
});
|
||||||
|
|
||||||
|
$('#contactForm').submit(function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var url = $(this).attr("action");
|
||||||
|
$.get(url, {
|
||||||
|
// 'from': $('#contactFrom').val(),
|
||||||
|
'to': $('#contactTo').val(),
|
||||||
|
'message': $('#contactMessage').val()
|
||||||
|
}, function(response) {
|
||||||
|
$('#contactDiv').text(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -63,6 +63,8 @@ urlpatterns = patterns('',
|
||||||
(r'^invitation/accept/(?P<invite_code>\w+)/','itfprofiles.views.invitation_accept'),
|
(r'^invitation/accept/(?P<invite_code>\w+)/','itfprofiles.views.invitation_accept'),
|
||||||
#(r'^invitation/add/$', 'itfprofiles.views.friend_add'),
|
#(r'^invitation/add/$', 'itfprofiles.views.friend_add'),
|
||||||
(r'^invitation/invite/$', 'itfprofiles.views.friend_invite'),
|
(r'^invitation/invite/$', 'itfprofiles.views.friend_invite'),
|
||||||
|
(r'^contact/person/$', 'itfprofiles.views.contact_person'),
|
||||||
|
(r'^contact/group/$', 'itfprofiles.views.contact_group'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# (r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
# (r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user