From 76788fb1f6deebf806a0199e6183ad6a9af4096a Mon Sep 17 00:00:00 2001
From: Evgeny Fadeev
Date: Sun, 22 Nov 2009 21:58:06 -0500
Subject: fixed broken links in few places, added Arvyd's modification of
user_reputation view, email sender cron job, some edits in INSTALL file
---
INSTALL | 26 +++++++++++++++--
cron/send_email_alerts | 4 +++
forum/feed.py | 4 +--
forum/views.py | 51 ++++++++++++++++++++-------------
templates/content/js/com.cnprog.post.js | 2 +-
templates/content/style/style.css | 5 +---
templates/question.html | 26 ++++++++---------
templates/user_reputation.html | 3 +-
templates/user_votes.html | 5 ++--
9 files changed, 81 insertions(+), 45 deletions(-)
create mode 100644 cron/send_email_alerts
diff --git a/INSTALL b/INSTALL
index 38d3a365..4b878f24 100644
--- a/INSTALL
+++ b/INSTALL
@@ -7,8 +7,10 @@ B. INSTALLATION
3. Running CNPROG in the development server
4. Installation under Apache/WSGI
5. Full text search
- 6. Miscellaneous
+ 6. Email subscriptions
+ 7. Miscellaneous
C. CONFIGURATION PARAMETERS (settings_local.py)
+D. CUSTOMIZATION
A. PREREQUISITES
@@ -201,7 +203,16 @@ WSGIPythonEggs /var/python/eggs #must be readable and writable by apache
remember that there must be trailing comma in parentheses for
SHPINX_SEARCH_INDICES tuple - particlarly with just one item!
-6. Miscellaneous
+6. Email subscriptions
+
+ This function at the moment requires Django 1.1
+
+ edit paths in the file cron/send_email_alerts
+ set up a cron job to call cron/send_email_alerts once or twice a day
+ subscription sender may be tested manually in shell
+ by calling cron/send_email_alerts
+
+7. Miscellaneous
There are some demo scripts under sql_scripts folder,
including badges and test accounts for CNProg.com. You
@@ -265,3 +276,14 @@ LOGIN_URL = '/%s%s%s' % (FORUM_SCRIPT_ALIAS,'account/','signin/')
DJANGO_VERSION = 1.1 #must be either 1.0 or 1.1
RESOURCE_REVISION=4 #increment when you update media files - clients will be forced to load new version
+
+D. Customization
+
+Other than settings_local.py the following will most likely need customization:
+* locale/*/django.po - language files that may also contain your site-specific messages
+ if you want to start with english messages file - look for words like "forum" and
+ "CNPROG" in the msgstr lines
+* templates/header.html and templates/footer.html may contain extra links
+* templates/about.html - a place to explain for is your forum for
+* templates/faq.html - put answers to users frequent questions
+* templates/content/style/style.css - modify style sheet to add disctinctive look to your forum
diff --git a/cron/send_email_alerts b/cron/send_email_alerts
new file mode 100644
index 00000000..e9e433be
--- /dev/null
+++ b/cron/send_email_alerts
@@ -0,0 +1,4 @@
+PYTHONPATH=/dir/just/above_forum
+export PYTHONPATH
+APP_ROOT=$PYTHONPATH/CNPROG
+/usr/local/bin/python $APP_ROOT/manage.py send_email_alerts >> $APP_ROOT/log/django.lanai.log
diff --git a/forum/feed.py b/forum/feed.py
index 373f8a87..ad1d5cbd 100644
--- a/forum/feed.py
+++ b/forum/feed.py
@@ -16,7 +16,7 @@ from models import Question
import settings
class RssLastestQuestionsFeed(Feed):
title = settings.APP_TITLE + _(' - ')+ _('latest questions')
- link = settings.APP_URL + '/' + _('questions/')
+ link = settings.APP_URL + '/' + _('question/')
description = settings.APP_DESCRIPTION
#ttl = 10
copyright = settings.APP_COPYRIGHT
@@ -34,7 +34,7 @@ class RssLastestQuestionsFeed(Feed):
return item.added_at
def items(self, item):
- return Question.objects.filter(deleted=False).order_by('-added_at')[:30]
+ return Question.objects.filter(deleted=False).order_by('-last_activity_at')[:30]
def main():
pass
diff --git a/forum/views.py b/forum/views.py
index 8f7d07fd..a1b37717 100644
--- a/forum/views.py
+++ b/forum/views.py
@@ -1739,32 +1739,43 @@ def user_votes(request, user_id, user_view):
def user_reputation(request, user_id, user_view):
user = get_object_or_404(User, id=user_id)
- reputation = Repute.objects.extra(
- select={'positive': 'sum(positive)', 'negative': 'sum(negative)', 'question_id':'question_id',
- 'title': 'question.title'},
- tables=['repute', 'question'],
- order_by=['-reputed_at'],
- where=['user_id=%s AND question_id=question.id'],
- params=[user.id]
- ).values('positive', 'negative', 'question_id', 'title', 'reputed_at', 'reputation')
-
- reputation.query.group_by = ['question_id']
-
+ try:
+ from django.db.models import Sum
+ reputation = Repute.objects.extra(
+ select={'question_id':'question_id',
+ 'title': 'question.title'},
+ tables=['repute', 'question'],
+ order_by=['-reputed_at'],
+ where=['user_id=%s AND question_id=question.id'],
+ params=[user.id]
+ ).values('question_id', 'title', 'reputed_at', 'reputation')
+ reputation = reputation.annotate(positive=Sum("positive"), negative=Sum("negative"))
+ except ImportError:
+ reputation = Repute.objects.extra(
+ select={'positive':'sum(positive)', 'negative':'sum(negative)', 'question_id':'question_id',
+ 'title': 'question.title'},
+ tables=['repute', 'question'],
+ order_by=['-reputed_at'],
+ where=['user_id=%s AND question_id=question.id'],
+ params=[user.id]
+ ).values('positive', 'negative', 'question_id', 'title', 'reputed_at', 'reputation')
+ reputation.query.group_by = ['question_id']
+
rep_list = []
for rep in Repute.objects.filter(user=user).order_by('reputed_at'):
dic = '[%s,%s]' % (calendar.timegm(rep.reputed_at.timetuple()) * 1000, rep.reputation)
rep_list.append(dic)
reps = ','.join(rep_list)
reps = '[%s]' % reps
-
- return render_to_response(user_view.template_file,{
- "tab_name" : user_view.id,
- "tab_description" : user_view.tab_description,
- "page_title" : user_view.page_title,
- "view_user" : user,
- "reputation" : reputation,
- "reps" : reps
- }, context_instance=RequestContext(request))
+
+ return render_to_response(user_view.template_file, {
+ "tab_name": user_view.id,
+ "tab_description": user_view.tab_description,
+ "page_title": user_view.page_title,
+ "view_user": user,
+ "reputation": reputation,
+ "reps": reps
+ }, context_instance=RequestContext(request))
def user_favorites(request, user_id, user_view):
user = get_object_or_404(User, id=user_id)
diff --git a/templates/content/js/com.cnprog.post.js b/templates/content/js/com.cnprog.post.js
index 58db9b33..0e604b8f 100644
--- a/templates/content/js/com.cnprog.post.js
+++ b/templates/content/js/com.cnprog.post.js
@@ -290,7 +290,7 @@ var Vote = function(){
fav.text(data.count);
}
else if(data.success == "1"){
- object.attr("src", $.i18n._("/") + "/content/images/vote-favorite-on.png");
+ object.attr("src", $.i18n._("/") + "content/images/vote-favorite-on.png");
var fav = getFavoriteNumber();
fav.text(data.count);
fav.addClass("my-favorite-number");
diff --git a/templates/content/style/style.css b/templates/content/style/style.css
index 65a323db..6c1d6a3f 100644
--- a/templates/content/style/style.css
+++ b/templates/content/style/style.css
@@ -163,7 +163,7 @@ blockquote
border-right:1px solid #b4b48e;
border-bottom:1px solid #b4b48e;*/
background: white;/* #f9f7ed;*/
- margin:10px 0 0 0;
+ margin:10px 0 10px 0;
/*background:url(../images/quest-bg.gif) repeat-x top;*/
}
#listA .qstA thumb {float:left; }
@@ -1144,9 +1144,6 @@ ul.bulleta li {background:url(../images/bullet_green.gif) no-repeat 0px 2px; pad
.message p {
margin-bottom:0px;
}
-.message p.space-above {
- margin-top:10px;
-}
.warning{color:red;}
.darkred{color:darkred;}
diff --git a/templates/question.html b/templates/question.html
index 6929b762..9183767f 100644
--- a/templates/question.html
+++ b/templates/question.html
@@ -139,10 +139,6 @@
{% if request.user|can_edit_post:question %}
{% trans 'edit' %}
{% endif %}
- {% separator %}
- {% if request.user|can_delete_post:question %}
- {% trans "delete" %}
- {% endif %}
{% separator %}
{% if question.closed %}
{% if request.user|can_reopen_question:question %}
@@ -163,6 +159,10 @@
{% endif %}
{% endif %}
+ {% separator %}
+ {% if request.user|can_delete_post:question %}
+ {% trans "delete" %}
+ {% endif %}
{% endjoinitems %}
@@ -293,15 +293,6 @@
{% if request.user|can_edit_post:answer %}
{% trans 'edit' %}
{% endif %}
- {% separator %}
- {% if request.user|can_delete_post:answer %}
- {% spaceless %}
-
-
- {% if answer.deleted %}{% trans "undelete" %}{% else %}{% trans "delete" %}{% endif %}
-
- {% endspaceless %}
- {% endif %}
{% separator %}
{% if request.user|can_flag_offensive %}
{% endif %}
+ {% separator %}
+ {% if request.user|can_delete_post:answer %}
+ {% spaceless %}
+
+
+ {% if answer.deleted %}{% trans "undelete" %}{% else %}{% trans "delete" %}{% endif %}
+
+ {% endspaceless %}
+ {% endif %}
{% endjoinitems %}
diff --git a/templates/user_reputation.html b/templates/user_reputation.html
index 29d642fe..16127140 100644
--- a/templates/user_reputation.html
+++ b/templates/user_reputation.html
@@ -1,6 +1,7 @@
{% extends "user.html" %}
{% load extra_tags %}
+{% load extra_filters %}
{% load humanize %}
{% block userjs %}
@@ -33,7 +34,7 @@
{{ rep.negative }}
- {{ rep.title }} ({{ rep.reputed_at }})
+ {{ rep.title }} ({{ rep.reputed_at }})
{% endfor %}
diff --git a/templates/user_votes.html b/templates/user_votes.html
index 4abbf46d..b72b3ef6 100644
--- a/templates/user_votes.html
+++ b/templates/user_votes.html
@@ -1,6 +1,7 @@
{% extends "user.html" %}
{% load extra_tags %}
+{% load extra_filters %}
{% load humanize %}
{% load i18n %}
@@ -18,9 +19,9 @@
--
cgit v1.2.3-1-g7c22