django xtd-comments, run sqldiff pls... and a bit of emailer 0.8

This commit is contained in:
Johnson Chetty 2012-11-14 11:55:16 +01:00
parent e8a0295a68
commit 17f6bbf687
12 changed files with 130 additions and 4 deletions

View File

@ -4,6 +4,11 @@ from models import *
#from django.contrib.contenttypes import generic #from django.contrib.contenttypes import generic
#from padmavideos.models import PadmaVideo, PadmaClip #from padmavideos.models import PadmaVideo, PadmaClip
# -- this is because settings.py uses
# COMMENTS_APP = "django_comments_xtd", then Comment needs to be registered
from django_comments_xtd import models as xtd
admin.site.register(xtd.Comment)
#class AudioInline(admin.StackedInline): #class AudioInline(admin.StackedInline):
# model = Audio # model = Audio
# extra = 2 # extra = 2

View File

@ -277,7 +277,6 @@ class Play(ItfModel):
title = models.CharField(max_length=512) title = models.CharField(max_length=512)
author = models.CharField(max_length=512, blank=True) author = models.CharField(max_length=512, blank=True)
year = models.IntegerField(null=True, blank=True, max_length=4) year = models.IntegerField(null=True, blank=True, max_length=4)
added_by = models.ForeignKey(User) added_by = models.ForeignKey(User)
def __unicode__(self): def __unicode__(self):
@ -310,12 +309,14 @@ class TheatreGroup(ItfModel):
#nature_of_work = models.CharField(max_length=255) #nature_of_work = models.CharField(max_length=255)
# founded = models.CharField(max_length=10) # founded = models.CharField(max_length=10)
trainings = generic.GenericRelation("Training") trainings = generic.GenericRelation("Training")
allow_comments = models.BooleanField('allow comments', default=True)
def __unicode__(self): def __unicode__(self):
return self.name return self.name
def get_dict(self): def get_dict(self):
return { return {
#'object':self,
'name': self.name, 'name': self.name,
'email': self.email, 'email': self.email,
'tel':self.tel, 'tel':self.tel,

View File

@ -97,6 +97,16 @@ def personpopup(request):
form = PersonForm(request.POST, request.FILES) form = PersonForm(request.POST, request.FILES)
if form.is_valid(): if form.is_valid():
instance = form.save() instance = form.save()
invitation = PersonInvitation(
invitee=invitee,
invite_code=User.objects.make_random_password(30),
is_validated=False,
inviter=Person.objects.get(user=request.user),
sent_date=datetime.now()
)
invitation.save()
invitation.send_mail()
#return HttpResponse("<html><body>This person will be Invited!</body></html>")
#return HttpResponse("<script>opener.dismissAddAnotherPopup(this, '%s', '%s')</script>" % (str(instance.id), instance.get_title())) #return HttpResponse("<script>opener.dismissAddAnotherPopup(this, '%s', '%s')</script>" % (str(instance.id), instance.get_title()))
else: else:
form = PersonForm() form = PersonForm()

View File

@ -231,8 +231,14 @@ INSTALLED_APPS = (
'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.github',
'emailconfirmation', 'emailconfirmation',
'django_comments_xtd',
) )
#j comments-xtd
COMMENTS_APP = "django_comments_xtd"
COMMENTS_XTD_CONFIRM_EMAIL = True
COMMENTS_XTD_MAX_THREAD_LEVEL = 0 # no threading
# jj all auth + email settings # jj all auth + email settings
LOGIN_REDIRECT_URL = '/edit_profile' LOGIN_REDIRECT_URL = '/edit_profile'

View File

@ -0,0 +1,20 @@
{% load comments i18n %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
{% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
{% for field in form %}
{% if field.is_hidden %}
<div>{{ field }}</div>
{% 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 %}
<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>

View File

@ -0,0 +1,10 @@
<dl id="comments">
{% for comment in comment_list %}
<dt id="c{{ comment.id }}">
{{ comment.submit_date }} - {{ comment.name }}
</dt>
<dd>
<p>{{ comment.comment }}</p>
</dd>
{% endfor %}
</dl>

View File

@ -0,0 +1,8 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}{% trans "Thanks for commenting" %}.{% endblock %}
{% block content %}
<h1>{% trans "Thank you for your comment" %}.</h1>
{% endblock %}

View File

@ -0,0 +1,36 @@
{% extends "comments/base.html" %}
{% load i18n %}
{% block title %}{% trans "Preview your comment" %}{% endblock %}
{% block content %}
{% load comments %}
<form action="{% comment_form_target %}" method="post">{% csrf_token %}
{% if next %}<div><input type="hidden" name="next" value="{{ next }}" /></div>{% endif %}
{% if form.errors %}
<h1>{% blocktrans count form.errors|length as counter %}Please correct the error below{% plural %}Please correct the errors below{% endblocktrans %}</h1>
{% else %}
<h1>{% trans "Preview your comment" %}</h1>
<blockquote>{{ comment|linebreaks }}</blockquote>
<p>
{% trans "and" %} <input type="submit" name="submit" class="submit-post" value="{% trans "Post your comment" %}" id="submit" /> {% trans "or make changes" %}:
</p>
{% endif %}
{% for field in form %}
{% if field.is_hidden %}
<div>{{ field }}</div>
{% 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 %}
<p class="submit">
<input type="submit" name="submit" class="submit-post" value="{% trans "Post" %}" />
<input type="submit" name="preview" class="submit-preview" value="{% trans "Preview" %}" />
</p>
</form>
{% endblock %}

View File

@ -202,6 +202,32 @@
<div id="notes" class="tab_content"> <div id="notes" class="tab_content">
{% load comments %}
<div id="comments">
{% get_comment_count for obj as comment_count %}
{% if comment_count %}
<H4 class="center">{{ comment_count }} comment{{ comment_count|pluralize }}</H4>
{% endif %}
<div id="comment-list">
{% render_comment_list for obj %}
</div>
{% if obj.allow_comments and user.is_authenticated %}
<H4 class="center">your comment</H4>
<div id="comment-form">
{% render_comment_form for obj %}
</div>
{% else %}
{% if user.is_authenticated %}
<h4 class="center"> Comments are disabled for this article</h4>
{% else %}
<h4 class="center"> </h4>
{% endif %}
{% endif %}
</div>
{% if awards %} {% if awards %}
<div id="" class="itfFormDisplay"> <div id="" class="itfFormDisplay">
<span class="orange">Awards: </span> <span class="orange">Awards: </span>

View File

@ -24,7 +24,8 @@ urlpatterns = patterns('',
(r'^contact/$', 'frontpage.views.contact'), (r'^contact/$', 'frontpage.views.contact'),
(r'^emailer/issue/(?P<issue_no>\d+)/$', 'emailer.views.show_emailer'), (r'^emailer/issue/(?P<issue_no>\d+)/$', 'emailer.views.show_emailer'),
# ('m/(?P<module_slug>.*)', 'insidepages.views.main'), # ('m/(?P<module_slug>.*)', 'insidepages.views.main'),
(r'^comments/', include('django.contrib.comments.urls')), #(r'^comments/', include('django.contrib.comments.urls')),
url(r'^comments/', include('django_comments_xtd.urls')),
# (r'^ckeditor/', include('ckeditor.urls')), # (r'^ckeditor/', include('ckeditor.urls')),
(r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}), (r'^robots.txt$', direct_to_template, {'template': 'robots.txt', 'mimetype': 'text/plain'}),
# (r'^erang/', include('erang_organised.urls')), # (r'^erang/', include('erang_organised.urls')),

View File

@ -0,0 +1,2 @@
ALTER TABLE `itfprofiles_theatregroup`
ADD `allow_comments` bool;

View File

@ -22,5 +22,6 @@ django-markitup
twitter twitter
-e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth -e git+git://github.com/pennersr/django-allauth.git#egg=django-allauth
-e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk -e git+git://github.com/pythonforfacebook/facebook-sdk.git#egg=facebook-sdk
django-comments-xtd
django-avatar django-avatar
imagestore imagestore