bunch of models meta foo; add fccv spam protection for comments
This commit is contained in:
parent
71fffbdf6a
commit
86258ec528
|
@ -4,7 +4,9 @@ from django.db.models import Q
|
||||||
from ox.text import smartSplit
|
from ox.text import smartSplit
|
||||||
from ox.django.fields import DictField
|
from ox.django.fields import DictField
|
||||||
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
from django.core.paginator import Paginator, InvalidPage, EmptyPage
|
||||||
|
from django.template.loader import render_to_string
|
||||||
|
from django.contrib.contenttypes.models import ContentType
|
||||||
|
from insidepages.models import ModuleTab
|
||||||
|
|
||||||
def splitSearch(string):
|
def splitSearch(string):
|
||||||
ret = []
|
ret = []
|
||||||
|
@ -19,6 +21,7 @@ class ItfModel(models.Model):
|
||||||
# related_models = []
|
# related_models = []
|
||||||
sort_fields = []
|
sort_fields = []
|
||||||
hasComments = True
|
hasComments = True
|
||||||
|
title_field = "title"
|
||||||
|
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
|
@ -30,9 +33,52 @@ class ItfModel(models.Model):
|
||||||
def info_dict(self):
|
def info_dict(self):
|
||||||
return self.get_dict()
|
return self.get_dict()
|
||||||
|
|
||||||
|
def get_title(self):
|
||||||
|
return self.get(self.title_field)
|
||||||
|
|
||||||
|
def get_tab(self):
|
||||||
|
ctype = ContentType.objects.get(model=self.__class__._meta.module_name)
|
||||||
|
tab = ModuleTab.objects.filter(model=ctype)[0]
|
||||||
|
return tab
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "%s?tab_id=%d&object_id=%d" % (self.get_module().get_absolute_url(), self.get_tab().id, self.id)
|
||||||
|
|
||||||
|
def get_module(self):
|
||||||
|
tab = self.get_tab()
|
||||||
|
if tab:
|
||||||
|
return tab.module
|
||||||
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def get_main_image(self):
|
||||||
|
return {
|
||||||
|
'url': '',
|
||||||
|
'caption': ''
|
||||||
|
}
|
||||||
|
|
||||||
|
def get_template_path(self):
|
||||||
|
kls = self.__class__
|
||||||
|
return "modules/%s/%s.html" % (kls._meta.app_label, kls._meta.module_name)
|
||||||
|
|
||||||
def get_dict(self):
|
def get_dict(self):
|
||||||
return self.get(self._get_fields().keys())
|
return self.get(self._get_fields().keys())
|
||||||
|
|
||||||
|
def insidepage_dict(self):
|
||||||
|
try:
|
||||||
|
html = render_to_string(self.get_template_path(), self.info_dict())
|
||||||
|
except:
|
||||||
|
html = "Template for this model not found."
|
||||||
|
return {
|
||||||
|
'url': self.get_absolute_url(),
|
||||||
|
'title': self.get_title(),
|
||||||
|
'main_image': self.get_main_image(),
|
||||||
|
'html': html
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get(self, props):
|
def get(self, props):
|
||||||
typ = type(props)
|
typ = type(props)
|
||||||
if typ == list:
|
if typ == list:
|
||||||
|
|
|
@ -96,7 +96,7 @@ class BestPracticeStory(models.Model):
|
||||||
'image': self.image.url if self.image.name != '' else ''
|
'image': self.image.url if self.image.name != '' else ''
|
||||||
}
|
}
|
||||||
|
|
||||||
class BestPracticeFAQ(models.Model):
|
class BestPracticeFAQ(ItfModel):
|
||||||
question = models.TextField()
|
question = models.TextField()
|
||||||
answer = models.TextField()
|
answer = models.TextField()
|
||||||
|
|
||||||
|
|
|
@ -141,6 +141,7 @@ INSTALLED_APPS = (
|
||||||
'registration',
|
'registration',
|
||||||
# 'itfcore',
|
# 'itfcore',
|
||||||
'festival',
|
'festival',
|
||||||
|
'insidepages',
|
||||||
'erang_organised',
|
'erang_organised',
|
||||||
'scriptbank',
|
'scriptbank',
|
||||||
'bestpractices',
|
'bestpractices',
|
||||||
|
@ -158,6 +159,7 @@ INSTALLED_APPS = (
|
||||||
'south',
|
'south',
|
||||||
'user',
|
'user',
|
||||||
'ckeditor',
|
'ckeditor',
|
||||||
|
'fccv',
|
||||||
)
|
)
|
||||||
|
|
||||||
ACCOUNT_ACTIVATION_DAYS = 30
|
ACCOUNT_ACTIVATION_DAYS = 30
|
||||||
|
|
|
@ -17,6 +17,8 @@ urlpatterns = patterns('',
|
||||||
# (r'^bhangar/', include('bhangar.foo.urls')),
|
# (r'^bhangar/', include('bhangar.foo.urls')),
|
||||||
#(r'^search/', include('solango.urls')),
|
#(r'^search/', include('solango.urls')),
|
||||||
(r'^t/$', "frontpage.views.index"),
|
(r'^t/$', "frontpage.views.index"),
|
||||||
|
(r'm/', include('insidepages.urls')),
|
||||||
|
# ('m/(?P<module_slug>.*)', 'insidepages.views.main'),
|
||||||
(r'^comments/', include('django.contrib.comments.urls')),
|
(r'^comments/', include('django.contrib.comments.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'}),
|
||||||
|
|
|
@ -10,3 +10,4 @@ django-extensions
|
||||||
django-debug-toolbar
|
django-debug-toolbar
|
||||||
South
|
South
|
||||||
django-ckeditor
|
django-ckeditor
|
||||||
|
fccv #for comment-spam protection
|
||||||
|
|
Loading…
Reference in New Issue
Block a user