diff options
-rw-r--r-- | docs/source/install.rst | 99 | ||||
-rw-r--r-- | docs/source/upgrade.rst | 78 | ||||
-rw-r--r-- | papillon/local_settings.py.sample | 38 | ||||
-rw-r--r-- | papillon/polls/feeds.py | 14 | ||||
-rw-r--r-- | papillon/settings.py (renamed from papillon/settings.py.tpl) | 34 | ||||
-rw-r--r-- | papillon/templates/base.html | 2 | ||||
-rw-r--r-- | papillon/urls.py | 9 |
7 files changed, 169 insertions, 105 deletions
diff --git a/docs/source/install.rst b/docs/source/install.rst index 1defe38..a48bb35 100644 --- a/docs/source/install.rst +++ b/docs/source/install.rst @@ -22,7 +22,7 @@ Requirements - `python-markdown <http://sourceforge.net/projects/python-markdown/>`_ - - `django <http://www.djangoproject.com/>`_ version 1.2 + - `django <http://www.djangoproject.com/>`_ version 1.4 - `django-south <http://south.aeracode.org/>`_ version 0.7 @@ -32,7 +32,7 @@ Requirements The simple way to obtain theses elements is to get package from your favourite linux distribution. -For instance the packages for Debian squeeze are get with:: +For instance the packages for Debian wheezy are get with:: $ sudo apt-get install python python-django python-django-south $ sudo apt-get install python-markdown gettext apache2 @@ -47,7 +47,7 @@ Choose an install path First of all you have to choose an install path:: - $ INSTALL_PATH=/var/local/django/ + INSTALL_PATH=/var/local/django/ Of course you have to create it if it doesn't exist. @@ -58,31 +58,32 @@ The last "stable" version is available in this `directory <http://www.peacefrogs Another solution is to get it from the git repository:: - $ cd $INSTALL_PATH - $ git clone git://www.peacefrogs.net/git/papillon - $ cd papillon - $ git tag -l # list tagged versions - $ git checkout v0.3 # checkout the desired version + cd $INSTALL_PATH + git clone git://www.peacefrogs.net/git/papillon + cd papillon + git tag -l # list tagged versions + git checkout v0.3.1 # checkout the desired version Install the sources ------------------- If necessary unpack then move the sources in a directory readable to the apache user (www-data in Debian):: - $ cd $INSTALL_PATH - $ sudo tar xvjf /home/etienne/papillon-last.tar.bz2 - $ cd papillon - $ sudo chown -R etienne:www-data papillon + cd $INSTALL_PATH + sudo tar xvjf /home/etienne/papillon-last.tar.bz2 + cd papillon + sudo chown -R etienne:www-data papillon -In your Papillon application directory create settings.py to fit to your configuration. -A base template is provided (settings.py.tpl). The main parameters to change are pointed here:: +In your Papillon application directory copy **local_settings.py.sample** to **local_settings.py**. +There is juste a few parameters to give.:: + + cd $INSTALL_PATH + cd papillon/papillon + PAPILLON_PATH=`pwd` + cp local_settings.py.sample local_settings.py + vim local_settings.py - $ cd $INSTALL_PATH - $ cd papillon/papillon - $ PAPILLON_PATH=`pwd` - $ cp settings.py.tpl settings.py - $ nano settings.py #### EXTRA_URL = '' # extra_url path @@ -92,7 +93,7 @@ A base template is provided (settings.py.tpl). The main parameters to change are (...) DATABASES = { 'default': { - 'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. + 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'papillon', # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. @@ -111,42 +112,42 @@ If your Papillon is going to be used by many people, it is recommanded to use a In the directory Papillon, put up a symbolic link to the basic styles django (change the path depending on your installation of django):: - $ cd $PAPILLON_PATH - $ ln -s . + cd $PAPILLON_PATH + ln -s /usr/share/pyshared/django/contrib/admin/static/admin/ static/ Database initialisation ----------------------- In the directory Papillon simply:: - $ cd $PAPILLON_PATH - $ ./manage.py syncdb + cd $PAPILLON_PATH + ./manage.py syncdb Answer the questions to create an administrator (administration pages can be found at: http://where_is_papillon/admin) then:: - $ cd $PAPILLON_PATH - $ ./manage.py migrate polls + cd $PAPILLON_PATH + ./manage.py migrate polls If you use sqlite (default database) give the write rights on the database file to the apache user:: - $ cd $PAPILLON_PATH - $ chmod g+w papillon.db - $ chmod g+w . + cd $PAPILLON_PATH + chmod g+w papillon.db + chmod g+w . Compiling languages ------------------- If your language is available in the locale directory of Papillon, you will just need to get it compiled. Still being in the Papillon directory, this can be done with (here, "de" stands for german. Replace it with the appropriate language code):: - $ cd $PAPILLON_PATH - $ django-admin compilemessages -l de + cd $PAPILLON_PATH + django-admin compilemessages -l de If your language is not available, feel free to create the default po files and to submit it, contributions are well appreciated. Procedure is as follows. You first need to create the default po file (of course, replace "de" according to the language you chose to create):: - $ cd $PAPILLON_PATH - $ django-admin makemessages -l de + cd $PAPILLON_PATH + django-admin makemessages -l de There should now be a django.po file in locale/de/LC_MESSAGES. Complete it with your translation. @@ -176,43 +177,43 @@ Install with mod_python Install mod_python for apache:: - $ sudo apt-get install libapache2-mod-python + sudo apt-get install libapache2-mod-python Copy and adapt the choosen configuration file for Papillon:: - $ cd $INSTALL_PATH - $ sudo cp papillon/docs/conf/apache-modpython.conf /etc/apache2/sites-available/papillon - $ sudo nano /etc/apache2/sites-available/papillon + cd $INSTALL_PATH + sudo cp papillon/docs/conf/apache-modpython.conf /etc/apache2/sites-available/papillon + sudo nano /etc/apache2/sites-available/papillon Active this site, reload Apache and now your Papillon "can fly":: - $ sudo a2ensite papillon - $ sudo /etc/init.d/apache2 reload + sudo a2ensite papillon + sudo /etc/init.d/apache2 reload Install with mod_wsgi +++++++++++++++++++++++ Install mod_wsgi for apache:: - $ sudo apt-get install libapache2-mod-wsgi + sudo apt-get install libapache2-mod-wsgi Copy and adapt the apache configuration file for Papillon:: - $ cd $INSTALL_PATH - $ sudo cp docs/conf/apache-wsgi.conf /etc/apache2/sites-available/papillon - $ sudo nano /etc/apache2/sites-available/papillon + cd $INSTALL_PATH + sudo cp docs/conf/apache-wsgi.conf /etc/apache2/sites-available/papillon + sudo nano /etc/apache2/sites-available/papillon Copy and adapt the wsgi configuration file for Papillon:: - $ cd $INSTALL_PATH - $ sudo mkdir apache - $ sudo cp docs/conf/django.wsgi apache/ - $ sudo nano apache2/django.wsgi + cd $INSTALL_PATH + sudo mkdir apache + sudo cp docs/conf/django.wsgi apache/ + sudo nano apache2/django.wsgi Active this site, reload Apache and now your Papillon "can fly" (with WSGI wings):: - $ sudo a2ensite papillon - $ sudo /etc/init.d/apache2 reload + sudo a2ensite papillon + sudo /etc/init.d/apache2 reload Post-installation diff --git a/docs/source/upgrade.rst b/docs/source/upgrade.rst index 24f7d44..d049a4b 100644 --- a/docs/source/upgrade.rst +++ b/docs/source/upgrade.rst @@ -8,12 +8,12 @@ Upgrade :Date: 2011-10-25 :Copyright: CC-BY 3.0 +Preliminary +----------- + This document presents the upgrade from one version of Papillon to another. Instructions are given for Debian and bash but they are easy to adapt to other distribution and other shells. -From version 0.2 (and prior) to 0.3 ------------------------------------ - First of all copy the installation path, the config files and your database. Then you'll be able to rollback if there is any problem. @@ -21,36 +21,59 @@ Disable your installation in Apache *********************************** :: - $ sudo a2dissite papillon - $ sudo /etc/init.d/apache2 reload + sudo a2dissite papillon + sudo /etc/init.d/apache2 reload Upgrade sources *************** Get the new sources. Extract the tarball (from the download `directory <http://www.peacefrogs.net/download/>`_) or clone the git repository in a temporary directory:: - $ cd /tmp/ - $ git clone git://www.peacefrogs.net/git/papillon - $ cd papillon - $ git tag -l # list tagged versions - $ git checkout v0.3.0 # checkout the desired version + cd /tmp/ + git clone git://www.peacefrogs.net/git/papillon + cd papillon + git tag -l # list tagged versions + git checkout v0.4.0 # checkout the desired version Copy updated files to your installation (be careful to put trailing slash):: - $ PAPILLON_PATH=/var/local/django/papillon/ - $ sudo rsync -raP /tmp/papillon/ $PAPILLON_PATH + PAPILLON_PATH=/var/local/django/papillon/ + sudo rsync -raP /tmp/papillon/ $PAPILLON_PATH As the Git is now used you can remove (if any) Subversion directory in your new installation:: - $ cd $PAPILLON_PATH - $ sudo find . -name ".svn" -exec rm -rf {} \; + cd $PAPILLON_PATH + sudo find . -name ".svn" -exec rm -rf {} \; + +From version 0.3 to 0.4 +----------------------- + +New dependencies +**************** + +Papillon needs now at least Django version 1.4. Upgrade your version of Django. + +New settings management +*********************** + +Settings are not managed the same way. To manage properly the upgrade follow +theses steps (in the project directory): + +* Copy local_settings.py.sample to local_settings.py. +* Report your old configuration to local_settings.py (put only the fields that + defers from the new settings.py). +* Be careful: database engines have changed (the sample give you the new path to + sqlite engine). + +From version 0.2 (and prior) to 0.3 +----------------------------------- New dependencies **************** In order to simplify future database evolution `django-south <http://south.aeracode.org/>`_ is now used. To install it on a debian Squeeze:: - $ sudo aptitude install python-django-south + sudo aptitude install python-django-south "settings.py" changes @@ -58,12 +81,12 @@ In order to simplify future database evolution `django-south <http://south.aerac Many changes have to be made in settings.py. -Change any occurence of ROOT_PATH to PROJECT_PATH:: +Change any occurrence of ROOT_PATH to PROJECT_PATH:: - $ cd $PAPILLON_PATH - $ sed -i 's/ROOT_PATH/PROJECT_PATH/g' papillon/settings.py + cd $PAPILLON_PATH + sed -i 's/ROOT_PATH/PROJECT_PATH/g' papillon/settings.py -Change the manualy set definition of the project path by the lines:: +Change the manually set definition of the project path by the lines:: import os.path PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) @@ -136,19 +159,22 @@ Update database *************** :: - $ cd $PAPILLON_PATH - $ cd papillon - $ ./manage.py syncdb - $ ./manage.py migrate polls --fake + cd $PAPILLON_PATH + cd papillon + ./manage.py syncdb + ./manage.py migrate polls --fake Regeneration of translations **************************** :: - $ cd $PAPILLON_PATH - $ cd papillon - $ ./manage.py compilemessages -l fr + cd $PAPILLON_PATH + cd papillon + ./manage.py compilemessages -l fr + +Finish your update +------------------ Enable your new installation in Apache ************************************** diff --git a/papillon/local_settings.py.sample b/papillon/local_settings.py.sample new file mode 100644 index 0000000..8070842 --- /dev/null +++ b/papillon/local_settings.py.sample @@ -0,0 +1,38 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +# copy this file to local_settings.py and modify it to your needs + +DEBUG=False + +import os +PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) + +# Make this unique, and don't share it with anybody. +SECRET_KEY = 'replace_this_with_something_else' + +# if you have set an EXTRA_URL set the full path +EXTRA_URL = '' + +TINYMCE_URL = 'http://localhost/tinymce/' +MAX_COMMENT_NB = 10 # max number of comments by poll - 0 to disable comments +ALLOW_FRONTPAGE_POLL = False # disabled is recommanded for public instance +# time to live in days +DAYS_TO_LIVE = 30 + +ADMINS = ( + # ('Your Name', 'your_email@domain.com'), +) + +MANAGERS = ADMINS + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': PROJECT_PATH + '/papillon.db', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. + } +} diff --git a/papillon/polls/feeds.py b/papillon/polls/feeds.py index 126dbe0..b062590 100644 --- a/papillon/polls/feeds.py +++ b/papillon/polls/feeds.py @@ -21,17 +21,19 @@ import time from django.core.urlresolvers import reverse from django.core.exceptions import ObjectDoesNotExist -from django.contrib.syndication.feeds import Feed +from django.contrib.syndication.views import Feed from django.utils.translation import gettext_lazy as _ +from django.utils.safestring import mark_safe from papillon.polls.models import Poll, Vote, Voter class PollLatestEntries(Feed): - def get_object(self, poll_url): + def get_object(self, request, poll_url): + self.request = request if len(poll_url) < 1: raise ObjectDoesNotExist - return Poll.objects.get(base_url=poll_url[0]) + return Poll.objects.get(base_url=poll_url) def title(self, obj): return _("Papillon - poll : ") + obj.name @@ -44,7 +46,7 @@ class PollLatestEntries(Feed): return uri def description(self, obj): - return obj.description + return mark_safe(obj.description) def item_link(self, voter): url = reverse('poll', args=[voter.poll.base_url]) @@ -55,6 +57,6 @@ class PollLatestEntries(Feed): return url def items(self, obj): - voters = Voter.objects.filter(poll__id=obj.id).\ -order_by('-modification_date')[:10] + voters = Voter.objects.filter(poll=obj + ).order_by('-modification_date')[:10] return voters diff --git a/papillon/settings.py.tpl b/papillon/settings.py index cecfb45..49b46c5 100644 --- a/papillon/settings.py.tpl +++ b/papillon/settings.py @@ -2,11 +2,12 @@ # -*- coding: utf-8 -*- # Django settings for papillon project. +# Don't edit this file. Put your changes in local_settings.py -DEBUG = True +DEBUG = False TEMPLATE_DEBUG = DEBUG -import os.path +import os PROJECT_PATH = os.path.dirname(os.path.abspath(__file__)) EXTRA_URL = 'papillon/' @@ -25,17 +26,15 @@ MANAGERS = ADMINS DATABASES = { 'default': { - 'ENGINE': 'sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': PROJECT_PATH + '/papillon.db', # Or path to database file if using sqlite3. - 'USER': 'postgres', # Not used with sqlite3. - 'PASSWORD': '', # Not used with sqlite3. - 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. - 'PORT': '', # Set to empty string for default. Not used with sqlite3. + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': PROJECT_PATH + '/papillon.db', # Or path to database file if using sqlite3. + 'USER': '', # Not used with sqlite3. + 'PASSWORD': '', # Not used with sqlite3. + 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. + 'PORT': '', # Set to empty string for default. Not used with sqlite3. } } - - # Local time zone for this installation. Choices can be found here: # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE # although not all variations may be possible on all operating systems. @@ -67,16 +66,14 @@ MEDIA_URL = '/static/' # trailing slash. # Examples: "http://foo.com/media/", "/media/". # if you have set an EXTRA_URL set the full path -ADMIN_MEDIA_PREFIX = '/media/' +ADMIN_MEDIA_PREFIX = '/static/admin/' -# Make this unique, and don't share it with anybody. -SECRET_KEY = 'replace_this_with_something_else' +SECRET_KEY = '' # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( - 'django.template.loaders.filesystem.load_template_source', - 'django.template.loaders.app_directories.load_template_source', -# 'django.template.loaders.eggs.load_template_source', + 'django.template.loaders.filesystem.Loader', + 'django.template.loaders.app_directories.Loader', ) MIDDLEWARE_CLASSES = ( @@ -116,3 +113,8 @@ LANGUAGES = ( ('fr', 'Français'), ('en', 'English'), ) + +try: + from local_settings import * +except ImportError, e: + print 'Unable to load local_settings.py:', e diff --git a/papillon/templates/base.html b/papillon/templates/base.html index 30b1bf3..df72339 100644 --- a/papillon/templates/base.html +++ b/papillon/templates/base.html @@ -19,7 +19,7 @@ {% block content %}{% endblock %} </div> <div id="footer"> -<a href='http://blog.peacefrogs.net/nim/papillon/'>Papillon</a> - <a href='http://www.gnu.org/licenses/gpl.html'>Copyright</a> © 2008-2011 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a> +<a href='http://blog.peacefrogs.net/nim/papillon/'>Papillon</a> - <a href='http://www.gnu.org/licenses/gpl.html'>Copyright</a> © 2008-2013 <a href='http://redmine.peacefrogs.net/projects/show/papillon'>Papillon project</a> </div> </div> </body> diff --git a/papillon/urls.py b/papillon/urls.py index 862f66a..e0e9ed6 100644 --- a/papillon/urls.py +++ b/papillon/urls.py @@ -25,10 +25,6 @@ admin.autodiscover() from polls.feeds import PollLatestEntries -feeds = { - 'poll': PollLatestEntries, -} - base = '^' + settings.EXTRA_URL if settings.EXTRA_URL and not base.endswith('/'): base += '/' @@ -37,7 +33,7 @@ urlpatterns = patterns('', (base + r'admin/doc/', include('django.contrib.admindocs.urls')), url(base + r'admin/jsi18n/$', 'django.views.i18n.javascript_catalog', name='admin_i18n'), - (base + r'admin/(.*)', admin.site.root), + url(base + r'^admin/', include(admin.site.urls)), url(base + r'$', 'papillon.polls.views.index', name='index'), url(base + r'create/$', 'papillon.polls.views.create', name='create'), url(base + r'edit/(?P<admin_url>\w+)/$', @@ -52,8 +48,7 @@ urlpatterns = patterns('', name='poll'), url(base + r'poll/(?P<poll_url>\w+)/vote/$', 'papillon.polls.views.poll', name='vote'), - url(base + r'feeds/(?P<url>.*)$', 'django.contrib.syndication.views.feed', - {'feed_dict': feeds}, name='feed'), + url(base + r'feeds/poll/(?P<poll_url>\w+)$', PollLatestEntries(), name='feed'), (base + r'static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.PROJECT_PATH + '/static'}), (base + r'media/(?P<path>.*)$', 'django.views.static.serve', |