--- a/.hgignore Tue May 06 15:55:24 2014 +0200
+++ b/.hgignore Fri May 09 16:52:14 2014 +0200
@@ -9,10 +9,18 @@
develop-eggs
downloads
.settings
-
src/comt.egg-info
.installed.cfg
recreate
.pydevproject
settings_local.py
+settings_dev.py
urls_local.py
+dev/.vagrant
+dev/custom.yaml
+test-suite/node_modules
+test-suite/workspace.info*.js
+test-suite/clean-testserver.sh
+test-suite/karma.conf.dev.js
+test-suite/start-test-suite-dev.sh
+test-suite/start-testserver.sh
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgsub Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,6 @@
+dev/modules/nginx = [git]https://github.com/jfryman/puppet-nginx.git
+dev/modules/stdlib = [git]https://github.com/puppetlabs/puppetlabs-stdlib.git
+dev/modules/apt = [git]https://github.com/puppetlabs/puppetlabs-apt.git
+dev/modules/postgresql = [git]https://github.com/puppetlabs/puppetlabs-postgresql.git
+dev/modules/supervisord = [git]https://github.com/adedommelin/puppet-supervisord.git
+dev/modules/concat = [git]https://github.com/puppetlabs/puppetlabs-concat.git
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgsubstate Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,6 @@
+d33a4c103f625fbc0a68e5fd07d476e3ef9b0723 dev/modules/apt
+7ede29bd8edb12b9b57b30af23fa0f3d1e3281ee dev/modules/concat
+cd95690796851ca6c1b5d03b9584920dfd9a4bf0 dev/modules/nginx
+702998d8fd9a843fad13df8d9035ef1acce9a000 dev/modules/postgresql
+17a912ea0afb3fb018170477856c25a95009f2cc dev/modules/stdlib
+f1f5e323065c2a804527e0e5eb83a73ad321577b dev/modules/supervisord
--- a/README.txt Tue May 06 15:55:24 2014 +0200
+++ b/README.txt Fri May 09 16:52:14 2014 +0200
@@ -42,7 +42,7 @@
(all other python dependencies will be downloaded by buildout)
Installation (development install)
-============
+==================================
1. Install python2.5+ and all required libraries
(ubuntu users : 'sudo apt-get install python python-magic python-setuptools python-uno libyaml-0-1 python-yaml python-dev git-core python-utidylib python-pexpect python-cssutils')
2. Install pandoc
@@ -85,8 +85,50 @@
- `./bin/django runserver --settings=settings`
11. Access your Comt instance by pointing your browser to http://127.0.0.1:8000/
+Installation (Vagrant development box)
+======================================
+
+The second option is to use the vagrant virtual machine defined in the `dev` folder.
+For this you need first to install Vagrant for your platform (c.f. http://www.vagrantup.com/), open a terminal in the `dev` folder and launch the command
+<code>
+$ vagrant up
+</code>
+This will create a virtual box, using the private address 172.16.1.2. An instance of comt can be reached at the following url http://172.16.1.2.
+
+The installation have the following parameters:
+ - The root of the project is mapped on `/srv/comt` on the dev box.
+ - The web server is nginx (http://nginx.org/).
+ - The web pages are served as a wsgi application with gunicorn (http://gunicorn.org/).
+ - The gunicorn processes are monitored by supervisor (http://supervisord.org/).
+ - Openoffice is installed but is not launched as an headless instance (althought it could be easily setup with supervisor).
+ - The dev box uses a virtual network with the ip 172.16.1.2 (this can be changed in the Vagrant config).
+ - The box is provisioned using puppet (http://puppetlabs.com/).
+ - Most of the configuration is don in the sysconfig module found in `dev/modules/sysconfig`.
+ - All the other subdirectories of `dev/modules` are puppet modules used during the box provisioning. All the folders are sub-repositories and are checked-out using git.
+
+Moreover, the following parameters are set :
+
+ | var name | default |
+ |----------------|-------------|
+ | db_name | coment |
+ | db_user | coment_user |
+ | db_pw | coment |
+ | db_host | 127.0.0.1 |
+ | db_port | 5432 |
+ | superuser_name | admin |
+ | superuser_pw | dev@co-ment |
+
+These values can be overriden by creating a `custom.yaml` file in the `dev` folder. The file `custom.yaml.tmpl` gives a template for the format of this file.
+if the db_host is empty or 'localhost', or '127.0.0.1', the database is considered local to the box and a postgresql server is installed in the virtual server.
+Otherwise, the server is considered remote and only the postgresql client libraries are installed on the dev box.
+Also in this case, the database (db_name) and user (db_user) are not created automatically.
+You must ensure that they are already created on the postgresql server with the adequate authorizations, and that the user can connect on the 'remote' server from the dev box.
+
+Please refer to the available online documentation for more details on the various tools used here.
+
+
Installation (production environment)
-=============
+=====================================
This README.txt does not cover in details a production environment because this kind of setup is too platform dependant for us to provide a guide.
A few tips thought:
- recommended way to install it is using apache and wsgi, check out django installation guide at http://www.djangoproject.com/documentation/modpython/
@@ -116,7 +158,7 @@
To use openoffice, on a development setup, you should make sure no openoffice process is left and launch `soffice -headless "-accept=socket,port=2002;urp;"` to start openoffice in background mode.
Comt uses
-============
+=========
Javascript libs used (and license) / shipped with the distribution
------------------------------------------------------------------
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/buildout-prod.cfg Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,11 @@
+[buildout]
+extends = buildout.cfg
+parts += gunicorn
+
+[gunicorn]
+recipe = zc.recipe.egg:scripts
+dependent-scripts = true
+eggs =
+ ${python:eggs}
+ eventlet
+ gunicorn
--- a/buildout.cfg Tue May 06 15:55:24 2014 +0200
+++ b/buildout.cfg Fri May 09 16:52:14 2014 +0200
@@ -1,16 +1,20 @@
[buildout]
newest=false
+find-links = http://download.berlios.de/utidylib/uTidylib-0.2.zip
parts =
django
python
django-extensions
- django-piston
+ utidylib
omelette
unzip = true
develop = .
[versions]
django = 1.3
+utidylib = 0.2
+django-tagging = 0.3.1
+psycopg2 = 2.4.1
[python]
recipe = zc.recipe.egg
@@ -27,36 +31,40 @@
#test = cm
pythonpath = src
src/cm
+ extras
${django-extensions:location}
- ${django-piston:location}
eggs =
django-flash
django-tagging
-# django-piston
+ django-piston
# api dependency
# django-css
-# chardet
+ chardet
feedparser
- PIL
+ Pillow
BeautifulSoup
html5lib
pytz
simplejson
pyyaml
south
-# psycopg2/mysql should be optional dependencies ... possible with buildout ???
-# magic ???????? http://www.jsnp.net/code/magic.py ??? impossible to include this dependency
-# utidylib ?????? http://download.berlios.de/utidylib/uTidylib-0.2.zip
+ psycopg2
+ utidylib
+ cssutils
+ pexpect
[django-extensions]
recipe=zerokspot.recipe.git
repository=git://github.com/django-extensions/django-extensions.git
#rev=7c73978b55fcadbe2cd6f2abbefbedb5a85c2c8c
-[django-piston]
-recipe = mercurialrecipe
-repository = http://bitbucket.org/jespern/django-piston
+
+[utidylib]
+recipe = zc.recipe.egg
+eggs = uTidylib
+
[omelette]
recipe = collective.recipe.omelette
eggs = ${django:eggs}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/Vagrantfile Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,139 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+require 'yaml'
+
+custom_file_path = File.join(__dir__, (ENV['SYSCONFIG'] || 'custom.yaml'))
+
+context = (File.exist?(custom_file_path)?YAML::load_file(custom_file_path):{}) || {}
+
+ROOT_PATH = context.fetch("root_path","../")
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+ # All Vagrant configuration is done here. The most common configuration
+ # options are documented and commented below. For a complete reference,
+ # please see the online documentation at vagrantup.com.
+
+ # Every Vagrant virtual environment requires a box to build off of.
+ config.vm.box = context.fetch("vm_box","wheezy-73-x64")
+
+ # The url from where the 'config.vm.box' box will be fetched if it
+ # doesn't already exist on the user's system.
+ config.vm.box_url = context.fetch("vm_box_url","http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box")
+
+ # Create a forwarded port mapping which allows access to a specific port
+ # within the machine from a port on the host machine. In the example below,
+ # accessing "localhost:8080" will access port 80 on the guest machine.
+ # config.vm.network :forwarded_port, guest: 80, host: 8080
+
+ # Create a private network, which allows host-only access to the machine
+ # using a specific IP.
+ config.vm.network :private_network, ip: (ENV['VM_IP'] || context['vm_ip'] || "172.16.1.2")
+
+ # Create a public network, which generally matched to bridged network.
+ # Bridged networks make the machine appear as another physical device on
+ # your network.
+ # config.vm.network :public_network
+
+ # If true, then any SSH connections made will enable agent forwarding.
+ # Default value: false
+ # config.ssh.forward_agent = true
+
+ # Share an additional folder to the guest VM. The first argument is
+ # the path on the host to the actual folder. The second argument is
+ # the path on the guest to mount the folder. And the optional third
+ # argument is a set of non-required options.
+ config.vm.synced_folder ROOT_PATH, "/srv/comt"
+
+ vmname = (ENV['VM_NAME'] || context['vm_name'] || "coment_dev")
+
+ config.vm.define :"#{vmname}" do |coment_dev|
+ end
+
+ # Provider-specific configuration so you can fine-tune various
+ # backing providers for Vagrant. These expose provider-specific options.
+ # Example for VirtualBox:
+ #
+ config.vm.provider :virtualbox do |vb|
+ vb.name = vmname
+ # # Don't boot with headless mode
+ # vb.gui = true
+ #
+ # # Use VBoxManage to customize the VM. For example to change memory:
+ # vb.customize ["modifyvm", :id, "--memory", "1024"]
+ end
+ #
+ # View the documentation for the provider you're using for more
+ # information on available options.
+
+ # Enable provisioning with Puppet stand alone. Puppet manifests
+ # are contained in a directory path relative to this Vagrantfile.
+ # You will need to create the manifests directory and a manifest in
+ # the file base.pp in the manifests_path directory.
+ #
+ # An example Puppet manifest to provision the message of the day:
+ #
+ # # group { "puppet":
+ # # ensure => "present",
+ # # }
+ # #
+ # # File { owner => 0, group => 0, mode => 0644 }
+ # #
+ # # file { '/etc/motd':
+ # # content => "Welcome to your Vagrant-built virtual machine!
+ # # Managed by Puppet.\n"
+ # # }
+ #
+ config.vm.provision :puppet do |puppet|
+ puppet.manifests_path = "manifests"
+ puppet.manifest_file = "site.pp"
+ puppet.module_path = "modules"
+ puppet.options = "--hiera_config /vagrant/hiera.yaml"
+ puppet.facter = {
+ "vagrant_base_path" => File.dirname(__FILE__)
+ }
+ # puppet.options = "--debug --verbose --hiera_config /vagrant/hiera.yaml --graph --graphdir '/vagrant/graphs' --noop"
+
+ end
+
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
+ # some recipes and/or roles.
+ #
+ # config.vm.provision :chef_solo do |chef|
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
+ # chef.roles_path = "../my-recipes/roles"
+ # chef.data_bags_path = "../my-recipes/data_bags"
+ # chef.add_recipe "mysql"
+ # chef.add_role "web"
+ #
+ # # You may also specify custom JSON attributes:
+ # chef.json = { :mysql_password => "foo" }
+ # end
+
+ # Enable provisioning with chef server, specifying the chef server URL,
+ # and the path to the validation key (relative to this Vagrantfile).
+ #
+ # The Opscode Platform uses HTTPS. Substitute your organization for
+ # ORGNAME in the URL and validation key.
+ #
+ # If you have your own Chef Server, use the appropriate URL, which may be
+ # HTTP instead of HTTPS depending on your configuration. Also change the
+ # validation key to validation.pem.
+ #
+ # config.vm.provision :chef_client do |chef|
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+ # chef.validation_key_path = "ORGNAME-validator.pem"
+ # end
+ #
+ # If you're using the Opscode platform, your validator client is
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
+ #
+ # If you have your own Chef Server, the default validation client name is
+ # chef-validator, unless you changed the configuration.
+ #
+ # chef.validation_client_name = "ORGNAME-validator"
+end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/clean_dev.sh Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+pushd `dirname $0` > /dev/null
+SCRIPTPATH=`pwd -P`
+popd > /dev/null
+
+ROOTPATH="$SCRIPTPATH/.."
+
+pushd "$ROOTPATH" > /dev/null
+
+rm -rf .installed.cfg .mr.developer.cfg parts/ eggs/ develop-eggs/ bin/ \
+ src/cm/settings_local.py test-suite/workspace.info*.js \
+ test-suite/{clean-testserver.sh,karma.conf.dev.js} \
+ test-suite/{start-test-suite-dev.sh,start-testserver.sh}
+
+find . -name '*.pyc' -or -name '*.egg-info' | xargs rm -rvf
+
+popd > /dev/null
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/custom.yaml.tmpl Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,24 @@
+---
+#root_path : ../
+#vm_box : wheezy-73-x64
+#vm_box_url : http://puppet-vagrant-boxes.puppetlabs.com/debian-73-x64-virtualbox-puppet.box
+#vm_ip : 172.16.1.2
+#vm_name : coment_dev
+
+#sysconfig::params::db_name : coment_custom
+#sysconfig::params::db_user : coment_user_cutom
+#sysconfig::params::db_pw : coment_pw_custom
+#sysconfig::params::db_host : 127.0.0.1_custom
+#sysconfig::params::db_port : 5433
+
+#sysconfig::params::testserver_port : 8001
+
+#sysconfig::params::superuser_name : admin_custom
+#sysconfig::params::superuser_pw : dev@co-ment_custom
+#sysconfig::params::user_edit_name : user-edit
+#sysconfig::params::user_edit_pw : user-edit@co-ment
+#sysconfig::params::user_com_name : user-com
+#sysconfig::params::user_com_pw : user-com@co-ment
+#sysconfig::params::user_observ_name : user-observ
+#sysconfig::params::user_observ_pw : user-observ@co-ment
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/hiera.yaml Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,7 @@
+---
+:hierarchy:
+ - custom
+:backends:
+ - yaml
+:yaml:
+ :datadir: '/vagrant/'
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/manifests/site.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,36 @@
+exec {
+ 'apt_update_site':
+ command => '/usr/bin/apt-get update',
+ timeout => 2400,
+ returns => [ 0, 100 ];
+# refreshonly => true;
+}
+
+Exec["apt_update_site"] -> Package <| |>
+
+# upgrade system
+class { 'sysconfig::sys_upgrade': }->
+
+# install packages
+class { 'sysconfig::packages': }->
+
+# install postgres
+class { 'sysconfig::postgresql': }->
+
+# install nginx
+class { 'sysconfig::nginx': }->
+
+# create python
+class { 'sysconfig::buildout': }->
+
+# write config
+class { 'sysconfig::config': }->
+
+# write django_init
+class { 'sysconfig::django_init': }->
+
+# config testserver_init
+class { 'sysconfig::testserver_init': vagrant_base_path => $vagrant_base_path }->
+
+# deploy
+class { 'sysconfig::deploy': }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/files/clean-testserver.sh Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+PID=$(cat /tmp/testserver.pid|cut -d"|" -f1)
+OUTFILE=$(cat /tmp/testserver.pid|cut -d"|" -f2)
+
+echo "Kill test server pid $PID"
+kill $PID
+
+echo "Test server log:"
+echo "================================================================================"
+cat "$OUTFILE"
+echo "================================================================================"
+
+echo "Clean testserver output"
+rm "$OUTFILE"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/files/karma.conf.dev.js Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,50 @@
+// Karma configuration
+// Generated on Wed Jan 29 2014 15:32:16 GMT+0100 (CET)
+
+
+// SID: get WORKSPACE_URL configuration from one single file to customize
+var W = require ('./workspace.info.dev.js');
+
+module.exports = function(config) {
+ config.set({
+ // list of files or patterns to load in the browser, from current directory
+ files: [
+ {pattern: 'tests/**/*.js', included: true}
+ ],
+ // list of files to exclude
+ exclude: [ ],
+ // Start these browsers, currently available:
+ // - Firefox ; Safari (only Mac; run `npm install karma-safari-launcher` first)
+ // - Chrome ; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
+ // - PhantomJS ; IE (only Windows; run `npm install karma-ie-launcher` first)
+ browsers: W.BROWSERS,
+ // frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
+ frameworks: ['mocha', 'karma-e2e-dsl'],
+ // SID: Karma will start and run somewhere else than '/', to allow proxying '/'
+ urlRoot: '/karma/',
+ // SID: directive added on karma-e2e-dsl purpose. Map of path-proxy pairs.
+ proxies: {
+ '/': W.WORKSPACE_URL
+ },
+ client: {
+ mocha: {
+ ui: 'tdd'
+ },
+ W: W // SID: exports the variable in the test execution browser window
+ },
+ // test results reporter to use : 'dots', 'progress', 'junit', 'growl', 'coverage'
+ reporters: ['progress'],
+ // web server port
+ port: 9876,
+ // enable / disable colors in the output (reporters and logs)
+ colors: true,
+ // level of logging : config.LOG_DISABLE || _ERROR || _WARN || _INFO || _DEBUG
+ logLevel: config.LOG_INFO,
+ // If browser does not capture in given timeout [ms], kill it
+ captureTimeout: 20000,
+ // enable / disable watching file and executing tests whenever any file changes
+ autoWatch: false,
+ // Continuous Integration mode : if true, it capture browsers, run tests and exit
+ singleRun: true,
+ });
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/buildout.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,18 @@
+class sysconfig::buildout {
+
+ exec {
+ 'bootstrap':
+ command => '/usr/bin/python bootstrap.py',
+ cwd => '/srv/comt',
+ creates => '/srv/comt/bin',
+ user => 'vagrant';
+ 'buildout':
+ command => '/srv/comt/bin/buildout -c /srv/comt/buildout-prod.cfg',
+ cwd => '/srv/comt',
+ timeout => 0,
+ creates => '/srv/comt/bin/gunicorn';
+ }
+
+ Exec['bootstrap'] -> Exec['buildout']
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/config.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,29 @@
+class sysconfig::config(
+ $db_name = hiera('sysconfig::params::db_name',$sysconfig::params::db_name),
+ $db_user = hiera('sysconfig::params::db_user',$sysconfig::params::db_user),
+ $db_pw = hiera('sysconfig::params::db_pw',$sysconfig::params::db_pw),
+ $db_host = hiera('sysconfig::params::db_host',$sysconfig::params::db_host),
+ $db_port = hiera('sysconfig::params::db_port',$sysconfig::params::db_port)
+) inherits sysconfig::params {
+
+ notify {'config': name => "config -> \$db_host: ${db_host}, \$db_port: ${db_port}, \$db_name: ${db_name}, \$db_user: ${db_user}, \$db_pw: ${db_pw}", withpath => true }
+
+ file { 'local-settings':
+ ensure => 'present',
+ path => "/srv/comt/src/cm/settings_local.py",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 644,
+ content => template('sysconfig/settings_local.py.erb'),
+ }
+
+ file { 'media-root':
+ ensure => 'directory',
+ path => '/srv/comt/web',
+ owner => 'www-data',
+ group => 'www-data',
+ mode => '0775'
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/deploy.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,65 @@
+class sysconfig::deploy {
+
+ # create /var/run/gunicorn folder and insert entry in /etc/rc.local
+ file { 'run-folder':
+ path => '/var/run/gunicorn',
+ ensure => 'directory',
+ owner => 'www-data',
+ group => 'www-data',
+ mode => '0775',
+ }
+
+ #create run folder for gunicorn
+ file { 'rc.local':
+ path => '/etc/rc.local',
+ ensure => 'present',
+ mode => 755,
+ owner => 'root',
+ group => 'root',
+ content => template('sysconfig/rc.local.erb')
+ }
+
+ # install supervidsord
+ class { 'supervisord': }
+
+ supervisord::program { 'coment' :
+ command => '/srv/comt/bin/gunicorn -b unix:/var/run/gunicorn/comt.socket cm.wsgi:app',
+ user => 'www-data',
+ directory => '/srv/comt',
+ environment => "PYTHONPATH='/srv/comt/src',PROJECT_PATH='/srv/comt/src/cm'",
+ require => Class['supervisord']
+ }
+
+ supervisord::program { 'soffice' :
+ command => '/usr/bin/soffice --headless "--accept=socket,port=2002;urp;"',
+ user => 'vagrant',
+ directory => '/srv/comt',
+ autostart => false,
+ numprocs => 1,
+ require => Class['supervisord']
+ }
+
+ exec { 'reload_supervisor' :
+ command => '/usr/bin/supervisorctl update',
+ require => Supervisord::Program['coment']
+ }
+
+ #add site
+ nginx::resource::upstream { 'coment_app':
+ ensure => present,
+ members => [ 'unix:/var/run/gunicorn/comt.socket' ],
+ upstream_fail_timeout => 0,
+ require => Exec['reload_supervisor']
+ }
+
+ nginx::resource::vhost { $ipaddress_eth1:
+ ensure => present,
+ proxy => 'http://coment_app',
+ proxy_set_header => ['Host $http_host'],
+ vhost_cfg_append => {
+ 'proxy_redirect' => 'off'
+ },
+ require => Nginx::Resource::Upstream['coment_app']
+ }
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/django_init.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,27 @@
+class sysconfig::django_init (
+ $superuser_name = hiera('sysconfig::params::superuser_name', $sysconfig::params::superuser_name ),
+ $superuser_pw = hiera('sysconfig::params::superuser_pw' , $sysconfig::params::superuser_pw )
+) inherits sysconfig::params {
+
+ notify {'django_init': name => "django init \$superuser_name : ${superuser_name}, \$superuser_pw : ${superuser_pw}", withpath => true }->
+
+ exec { 'syncdb':
+ command => '/srv/comt/bin/django syncdb --noinput --migrate',
+ user => 'vagrant'
+ }
+
+ exec { 'loaddata':
+ command => '/srv/comt/bin/django loaddata roles_generic',
+ user => 'vagrant',
+ require => Exec['syncdb']
+ }
+
+ exec { 'createsuperuser':
+ command => "/bin/echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${superuser_name}', 'admin@example.com', '${superuser_pw}')\" | /srv/comt/bin/django shell",
+ cwd => '/srv/comt',
+ user => 'vagrant',
+ onlyif => "/bin/echo \"from django.contrib.auth.models import User; exit(User.objects.filter(username='${superuser_name}').count())\" | /srv/comt/bin/django shell",
+ require => Exec['syncdb']
+ }
+
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/init.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,4 @@
+
+class sysconfig {
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/nginx.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,6 @@
+class sysconfig::nginx {
+ # install nginx
+ class { '::nginx':}
+
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/packages.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,52 @@
+class sysconfig::packages {
+
+ $coment_pkgs = [
+ 'vim',
+ 'python-setuptools',
+ 'libpq-dev',
+ 'python-dev',
+ 'python-virtualenv',
+ 'libjpeg8-dev',
+ 'zlib1g-dev',
+ 'libtiff5-dev',
+ 'libfreetype6-dev',
+ 'liblcms2-dev',
+ 'libwebp-dev',
+ 'tcl-dev',
+ 'tk-dev',
+ 'python-magic',
+ 'mercurial',
+ 'libtidy-dev',
+ 'libyaml-dev',
+ 'git-core',
+ 'pandoc',
+ 'abiword',
+ 'libreoffice',
+ 'libreoffice-script-provider-python',
+ 'python-uno'
+ ]
+
+ package { $coment_pkgs: ensure => "installed" }
+
+ #upgrade setuptools
+ exec { '/usr/bin/easy_install --upgrade setuptools': require => Package[$coment_pkgs]}
+
+ augeas { "sshd_config":
+ context => "/files/etc/ssh/sshd_config",
+ changes => [
+ "set UseDNS no",
+ "set GSSAPIAuthentication no",
+ ],
+ notify => Service["sshd"],
+ }
+
+ service { "sshd":
+ name => $operatingsystem ? {
+ Debian => "ssh",
+ default => "sshd",
+ },
+ require => Augeas["sshd_config"],
+ enable => true,
+ ensure => running,
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/params.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,23 @@
+class sysconfig::params {
+
+ $db_name = 'coment'
+ $db_user = 'coment_user'
+ $db_pw = 'coment'
+ $db_host = '127.0.0.1'
+ $db_port = '5432'
+
+ $db_host_real = hiera('sysconfig::params::db_host',$db_host)
+ $db_is_local = ($db_host_real == undef or !$db_host_real or $db_host_real=='127.0.0.1' or $db_host_real=='localhost')
+
+ $testserver_port = 8001
+
+ $superuser_name = 'admin'
+ $superuser_pw = 'dev@co-ment'
+ $user_edit_name = 'user-edit'
+ $user_edit_pw = 'user-edit@co-ment'
+ $user_com_name = 'user-com'
+ $user_com_pw = 'user-com@co-ment'
+ $user_observ_name = 'user-observ'
+ $user_observ_pw = 'user-observ@co-ment'
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/postgresql.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,35 @@
+
+class sysconfig::postgresql (
+ $db_host = hiera('sysconfig::params::db_host', $sysconfig::params::db_host),
+ $db_port = hiera('sysconfig::params::db_port', $sysconfig::params::db_port),
+ $db_name = hiera('sysconfig::params::db_name', $sysconfig::params::db_name),
+ $db_user = hiera('sysconfig::params::db_user', $sysconfig::params::db_user),
+ $db_pw = hiera('sysconfig::params::db_pw', $sysconfig::params::db_pw),
+) inherits sysconfig::params {
+
+ notify {'postgresql': name => "\$db_host : ${db_host}, \$db_port : ${db_port}, \$db_name : ${db_name}, \$db_user : ${db_user}, \$db_pw : ${db_pw}", withpath => true }
+
+ if $sysconfig::params::db_is_local {
+ class { 'postgresql::server': }
+
+ postgresql::server::role {"${db_user}_createdb":
+ username => $db_user,
+ createdb => true,
+ password_hash => postgresql_password($db_user, $db_pw)
+ }->
+ postgresql::server::database { $db_name:
+ owner => $db_user,
+ encoding => 'UTF8',
+ }
+ }
+ else {
+ class { 'postgresql::client': }->
+ postgresql::validate_db_connection { 'validate_postgres_connection':
+ database_host => $db_host,
+ database_port => $db_port,
+ database_username => $db_user,
+ database_password => $db_pw,
+ database_name => $db_name,
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/sys_upgrade.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,21 @@
+class sysconfig::sys_upgrade {
+
+ exec {
+ 'apt_get_update_sysconfig':
+ command => '/usr/bin/apt-get update',
+ timeout => 2400,
+ returns => [ 0, 100 ];
+# refreshonly => true;
+ 'sys-upgrade':
+ command => '/usr/bin/apt-get upgrade -y',
+ timeout => 0,
+ require => Exec['apt_get_update_sysconfig'];
+ 'sys-dist-upgrade':
+ command => '/usr/bin/apt-get dist-upgrade -y',
+ timeout => 0,
+ require => Exec['apt_get_update_sysconfig'];
+ }
+
+ Exec['sys-upgrade'] -> Exec['sys-dist-upgrade']
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/manifests/testserver_init.pp Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,87 @@
+class sysconfig::testserver_init (
+ $superuser_name = hiera('sysconfig::params::superuser_name' ,$sysconfig::params::superuser_name ),
+ $superuser_pw = hiera('sysconfig::params::superuser_pw' ,$sysconfig::params::superuser_pw ),
+ $user_edit_name = hiera('sysconfig::params::user_edit_name' ,$sysconfig::params::user_edit_name ),
+ $user_edit_pw = hiera('sysconfig::params::user_edit_pw' ,$sysconfig::params::user_edit_pw ),
+ $user_com_name = hiera('sysconfig::params::user_com_name' ,$sysconfig::params::user_com_name ),
+ $user_com_pw = hiera('sysconfig::params::user_com_pw' ,$sysconfig::params::user_com_pw ),
+ $user_observ_name = hiera('sysconfig::params::user_observ_name' ,$sysconfig::params::user_observ_name ),
+ $user_observ_pw = hiera('sysconfig::params::user_observ_pw' ,$sysconfig::params::user_observ_pw ),
+ $testserver_port = hiera('sysconfig::params::testserver_port' ,$sysconfig::params::testserver_port ),
+ $vagrant_base_path
+
+) inherits sysconfig::params {
+
+ notify {'testserver_init': name => "testserver init : \$superuser_name : ${superuser_name}, \$superuser_pw : ${superuser_pw}", withpath => true }->
+
+ file { 'karma_workspace_info':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/workspace.info.js",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 644,
+ content => template('sysconfig/workspace.info.js.erb','sysconfig/url.workspace.info.js.erb'),
+ }
+
+ file { 'karma_workspace_info_dev':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/workspace.info.dev.js",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 644,
+ content => template('sysconfig/workspace.info.js.erb','sysconfig/url.test.workspace.info.js.erb'),
+ }
+
+ file { 'clean-testserver.sh':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/clean-testserver.sh",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 755,
+ source => 'puppet:///modules/sysconfig/clean-testserver.sh'
+ }
+
+ file { 'karma.conf.dev.js':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/karma.conf.dev.js",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 644,
+ source => 'puppet:///modules/sysconfig/karma.conf.dev.js'
+ }
+
+ file { 'start-test-suite-dev.sh':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/start-test-suite-dev.sh",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 755,
+ content => template('sysconfig/start-test-suite-dev.sh.erb')
+ }
+
+ file { 'start-testserver.sh':
+ ensure => 'present',
+ path => "/srv/comt/test-suite/start-testserver.sh",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 755,
+ content => template('sysconfig/start-testserver.sh.erb')
+ }
+
+ file { 'settings_dev':
+ ensure => 'present',
+ path => "/srv/comt/src/cm/settings_dev.py",
+ replace => 'no',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 644,
+ content => template('sysconfig/settings_dev.py.erb')
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/rc.local.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+#
+# rc.local
+#
+# This script is executed at the end of each multiuser runlevel.
+# Make sure that the script will "exit 0" on success or any other
+# value on error.
+#
+# In order to enable or disable this script just change the execution
+# bits.
+#
+# By default this script does nothing.
+
+if [ ! -d /var/run/gunicorn ]; then
+ mkdir /var/run/gunicorn/
+ chown www-data:www-data /var/run/gunicorn/
+fi
+
+exit 0
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/settings_dev.py.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,6 @@
+
+from settings import *
+
+DEBUG=True
+SITE_URL = "http://<%= @ipaddress_eth1 %>:<%= @testserver_port %>"
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/settings_local.py.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,87 @@
+DEBUG = True
+TEMPLATE_DEBUG = DEBUG
+CLIENT_DEBUG = DEBUG
+
+YUI_DEBUG = DEBUG # use expanded yui version (i.e. not -min)
+YUI_DISTANT = False
+
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'postgresql_psycopg2', # YOUR_SETTINGS # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+ 'NAME': '<%= @db_name %>', # YOUR_SETTINGS # Or path to database file if using sqlite3.
+ 'USER': '<%= @db_user %>', # YOUR_SETTINGS # Not used with sqlite3.
+ 'PASSWORD': '<%= @db_pw %>', # YOUR_SETTINGS # Not used with sqlite3.
+ 'HOST': '<%= @db_host %>', # YOUR_SETTINGS # Set to empty string for localhost. Not used with sqlite3.
+ 'PORT': '<%= @db_port %>', # YOUR_SETTINGS # Set to empty string for default. Not used with sqlite3.
+ }
+}
+
+SITE_URL = "http://<%= @ipaddress_eth1 %>" # YOUR_SETTINGS
+
+DEFAULT_FROM_EMAIL = "me@example.com" # YOUR_SETTINGS
+
+# destination email for the contact page
+CONTACT_DEST = DEFAULT_FROM_EMAIL
+
+# smtp host
+EMAIL_HOST = "localhost" # YOUR_SETTINGS
+
+TEMPLATE_STRING_IF_INVALID = "NNNNNNNNNOOOOOOOOOOOOOOO" if DEBUG else ''
+
+# web server writable directory to store Comt uploaded content (text images etc.)
+MEDIA_ROOT = '/srv/comt/web' # YOUR_SETTINGS
+
+# Insert some random text here,
+# it will be used to add some randomness to every crypto operation Comt does
+SECRET_KEY = '<%= Array.new(50){"abcdefghijklmnopqrstuvwxyz0123456789!@#\$%^&*(-_=+)".split("").sample}.join %>' # YOUR_SETTINGS
+
+MEDIA_URL = '/site_media/'
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'django.contrib.admin',
+ 'cm',
+# 'django_extensions',
+ 'tagging',
+ 'south',
+)
+
+CM_MEDIA_PREFIX = '/cmmedia/'
+
+ADMIN_MEDIA_PREFIX = '/media/'
+
+ADMINS = (
+ ('Comt admin', CONTACT_DEST),
+)
+
+MANAGERS = ADMINS
+SEND_BROKEN_LINK_EMAILS = False
+
+SERVER_EMAIL = DEFAULT_FROM_EMAIL
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+DEFAULT_TIME_ZONE = "Europe/Paris"
+
+# Do not use name/email of co-ment users but rather
+# those passed in the request.
+# Set this parameter to True when using co-ment from
+# a third-party CMS throuch co-ment API.
+DECORATED_CREATORS = False
+
+# Set to TRUE to use Abiword for convertion form and to legacy formats.
+# Set to False to use LibreOffice for convertion form and to legacy formats.
+USE_ABI = True
+
+# Set to True if you don't want to appear in Sopinspace Piwik statistics
+DISABLE_TRACKING = True
+
+#disable email reporting by piston
+PISTON_EMAIL_ERRORS = False
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/start-test-suite-dev.sh.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+echo "---------------------"
+echo "Starting test server"
+
+DEV_FOLDER="<%= @vagrant_base_path %>"
+
+pushd "$DEV_FOLDER" > /dev/null
+vagrant ssh -c "/srv/comt/test-suite/start-testserver.sh"
+popd > /dev/null
+
+
+TESTSERVER_STARTED=True
+WORKSPACE_INFO="workspace.info.dev.js"
+
+echo "---------------------"
+echo "Starting karma tests"
+. ./start-test-suite.sh ./karma.conf.dev.js $@
+
+echo "---------------------"
+echo "stopping test server + output test server logs"
+
+read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N)" -n 1 -r -t 5
+echo # (optional) move to a new line
+
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ exit 0
+fi
+
+pushd "$DEV_FOLDER" > /dev/null
+vagrant ssh -c "/srv/comt/test-suite/clean-testserver.sh"
+popd /dev/null
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/start-testserver.sh.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+
+ROOTPATH="/srv/comt"
+TMPFILE=`mktemp`
+
+pushd "$ROOTPATH" > /dev/null
+
+nohup bin/django testserver --settings=cm.settings_dev --noinput --addrport=0.0.0.0:<%= @testserver_port %> initial_data roles_generic test_suite > $TMPFILE 2>&1 &
+echo "$!|$TMPFILE" > /tmp/testserver.pid
+
+cat /tmp/testserver.pid
+
+popd > /dev/null
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/url.test.workspace.info.js.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,4 @@
+
+
+define ("WORKSPACE_URL", 'http://<%= @ipaddress_eth1 %>:<%= @testserver_port %>/');
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/url.workspace.info.js.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,4 @@
+
+
+define ("WORKSPACE_URL", 'http://<%= @ipaddress_eth1 %>/');
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/dev/modules/sysconfig/templates/workspace.info.js.erb Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,26 @@
+
+function define (name, value) {
+ Object.defineProperty (exports, name, {
+ value: value,
+ enumerable: true
+ });
+}
+
+define ("DEBUG", false);
+
+define ("USER_ADMIN", '<%= @superuser_name %>');
+define ("PASS_ADMIN", '<%= @superuser_pw %>');
+
+define ("BROWSERS", ['PhantomJS']);
+
+// TODO: decide wether we should populate workspaces with standard users or
+// create them on the fly ?
+
+define ("USER_EDIT", '<%= @user_edit_name %>');
+define ("PASS_EDIT", '<%= @user_edit_pw %>');
+
+define ("USER_COM", '<%= @user_com_name %>');
+define ("PASS_COM", '<%= @user_com_pw %>');
+
+define ("USER_OBSERV", '<%= @user_observ_name %>');
+define ("PASS_OBSERV", '<%= @user_observ_pw %>');
--- a/src/cm/fixtures/test_content.yaml Tue May 06 15:55:24 2014 +0200
+++ b/src/cm/fixtures/test_content.yaml Fri May 09 16:52:14 2014 +0200
@@ -9,14 +9,14 @@
username: user1
email: user1@here.dja
password: sha1$6efc5$cf1468825cd79fd2d6ddaf97738c8666053af349
-
+
- model : cm.userprofile
pk: 1
fields:
user: 1
- key: "up_key_1"
- adminkey: "up_adminkey_1"
- created: "2009-02-13 04:01:12"
+ key: "up_key_1"
+ adminkey: "up_adminkey_1"
+ created: "2009-02-13 04:01:12"
# user2
@@ -31,9 +31,9 @@
pk: 2
fields:
user: 2
- key: "up_key_2"
- adminkey: "up_adminkey_2"
- created: "2009-02-13 04:01:12"
+ key: "up_key_2"
+ adminkey: "up_adminkey_2"
+ created: "2009-02-13 04:01:12"
# user3
@@ -48,9 +48,9 @@
pk: 3
fields:
user: 3
- key: "up_key_3"
- adminkey: "up_adminkey_3"
- created: "2009-02-13 04:01:12"
+ key: "up_key_3"
+ adminkey: "up_adminkey_3"
+ created: "2009-02-13 04:01:12"
# user4
@@ -65,9 +65,9 @@
pk: 4
fields:
user: 4
- key: "up_key_4"
- adminkey: "up_adminkey_4"
- created: "2009-02-13 04:01:12"
+ key: "up_key_4"
+ adminkey: "up_adminkey_4"
+ created: "2009-02-13 04:01:12"
# user5
@@ -83,9 +83,9 @@
pk: 5
fields:
user: 5
- key: "up_key_5"
- adminkey: "up_adminkey_5"
- created: "2009-02-13 04:01:12"
+ key: "up_key_5"
+ adminkey: "up_adminkey_5"
+ created: "2009-02-13 04:01:12"
# user6: pending user
@@ -101,12 +101,25 @@
pk: 6
fields:
user: 6
- key: "up_key_6"
+ key: "up_key_6"
adminkey: "up_adminkey_6"
- is_suspended: True
- created: "2009-02-13 04:01:12"
+ is_suspended: True
+ created: "2009-02-13 04:01:12"
-############### texts ###############
+- model: auth.user
+ pk: 7
+ fields:
+ email: admin@mail.com
+ groups: []
+ is_active: true
+ is_staff: true
+ is_superuser: true
+ password: sha1$46d5d$f808afd06c731b7b4cf97919165183b497a620df
+ username: admin
+
+
+
+############### texts ###############
# text 1
- model : cm.text
@@ -117,10 +130,10 @@
last_text_version: null
title: 'title 1'
state: "approved"
- key: "text_key_1"
- adminkey: "text_adminkey_1"
+ key: "text_key_1"
+ adminkey: "text_adminkey_1"
user: 1
-
+
- model : cm.textversion
pk: 1
fields:
@@ -131,8 +144,8 @@
content: 'aaa bbb ccc ddd eee fff ggg'
text: 1
mod_posteriori: True
- key: "textversion_key_1"
- adminkey: "tv_adminkey_1"
+ key: "textversion_key_1"
+ adminkey: "tv_adminkey_1"
- model : cm.textversion
pk: 0
@@ -144,8 +157,8 @@
content: 'zzz hhhh aaa bbb ccc ddd eee fff ggg'
text: 1
mod_posteriori: True
- key: "textversion_key_0"
- adminkey: "tv_adminkey_0"
+ key: "textversion_key_0"
+ adminkey: "tv_adminkey_0"
# text 2
@@ -157,9 +170,9 @@
last_text_version: null
title: 'title 2'
state: "approved"
- key: "text_key_2"
+ key: "text_key_2"
adminkey: "text_adminkey_2"
- user: 1
+ user: 1
- model : cm.textversion
pk: 2
@@ -171,10 +184,10 @@
content: 'aaa bbb ccc ddd eee fff ggg'
text: 2
mod_posteriori: False
- key: "textversion_key_2"
- adminkey: "tv_adminkey_2"
-
-
+ key: "textversion_key_2"
+ adminkey: "tv_adminkey_2"
+
+
# text 3
- model : cm.text
@@ -185,9 +198,9 @@
last_text_version: null
title: 'title 3'
state: "approved"
- key: "text_key_3"
+ key: "text_key_3"
adminkey: "text_adminkey_3"
- user: 2
+ user: 2
- model : cm.textversion
pk: 3
@@ -196,187 +209,187 @@
modified: "2009-02-13 04:01:12"
title: 'title 3'
format: 'markdown'
- content: 'aaa bbb ccc ddd eee fff ggg
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
- long text
-
-
+ content: 'aaa bbb ccc ddd eee fff ggg
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
+ long text
+
+
long text'
text: 3
- key: "textversion_key_3"
- adminkey: "tv_adminkey_3"
+ key: "textversion_key_3"
+ adminkey: "tv_adminkey_3"
# text 4
-
+
- model : cm.text
pk: 4
fields:
@@ -385,8 +398,8 @@
last_text_version: null
title: 'title 4, public text'
state: "approved"
- key: "text_key_4"
- adminkey: "text_adminkey_4"
+ key: "text_key_4"
+ adminkey: "text_adminkey_4"
user: 1
- model : cm.textversion
@@ -399,11 +412,11 @@
content: 'aaa bbb ccc ddd eee fff ggg'
text: 4
mod_posteriori: True
- key: "textversion_key_4"
- adminkey: "tv_adminkey_4"
+ key: "textversion_key_4"
+ adminkey: "tv_adminkey_4"
# text 5
-
+
- model : cm.text
pk: 5
fields:
@@ -412,9 +425,9 @@
last_text_version: null
title: 'title 5, public text'
state: "approved"
- key: "text_key_5"
- adminkey: "text_adminkey_5"
- user: 1
+ key: "text_key_5"
+ adminkey: "text_adminkey_5"
+ user: 1
- model : cm.textversion
pk: 5
@@ -426,10 +439,10 @@
content: 'aaa bbb ccc ddd eee fff ggg'
text: 5
mod_posteriori: True
- key: "textversion_key_5"
- adminkey: "tv_adminkey_5"
+ key: "textversion_key_5"
+ adminkey: "tv_adminkey_5"
-############### userrole ###############
+############### userrole ###############
# user 1 is global Manager
# userrole 1
@@ -439,7 +452,7 @@
role: 1
user: 1
text: null
-
+
# user 2 is Editor on text 2
# userrole 2
- model : cm.userrole
@@ -484,7 +497,7 @@
role: 1
user: 4
text: null
-
+
# user 4 is Commentator on text 2 (downgrade from global Manager)
# userrole 7
@@ -503,7 +516,7 @@
role: 4
user: null
text: 4
-
+
# user null (anon is Commentator on text 5)
# userrole 9
- model : cm.userrole
@@ -512,23 +525,23 @@
role: 4
user: null
text: 5
-
+
############### comment ###############
# comment 1 (visible on text 2)
- model : cm.comment
pk: 1
fields:
- created: "2009-02-13 04:01:12"
+ created: "2009-02-13 04:01:12"
modified: "2009-02-13 04:01:12"
- start_wrapper: 0
+ start_wrapper: 0
end_wrapper: 0
- start_offset: 1
+ start_offset: 1
end_offset: 11
- title: "comment 1"
- content: "comment 1 content"
- content_html: "<p>comment 1 content, this <a href='http://localhost:8000/text/text_key_2/view/?comment_id_key=comment_id_key_4'>link</a> is a link to another comment, and <a href='http://www.lemonde.fr'>this one</a> is a link to lemonde</sp></p>"
- key: "comment_key_1"
+ title: "comment 1"
+ content: "comment 1 content"
+ content_html: "<p>comment 1 content, this <a href='http://localhost:8000/text/text_key_2/view/?comment_id_key=comment_id_key_4'>link</a> is a link to another comment, and <a href='http://www.lemonde.fr'>this one</a> is a link to lemonde</sp></p>"
+ key: "comment_key_1"
id_key: "comment_id_key_1"
adminkey: "comment_adminkey_1"
reply_to: null
@@ -540,16 +553,16 @@
- model : cm.comment
pk: 2
fields:
- created: "2009-02-13 04:01:13"
+ created: "2009-02-13 04:01:13"
modified: "2009-02-13 04:01:13"
- start_wrapper: 0
+ start_wrapper: 0
end_wrapper: 0
- start_offset: 1
+ start_offset: 1
end_offset: 11
- title: "comment 2"
- content: "comment 2 content"
- content_html: "<p>comment 2 content</p>"
- key: "comment_key_2"
+ title: "comment 2"
+ content: "comment 2 content"
+ content_html: "<p>comment 2 content</p>"
+ key: "comment_key_2"
id_key: "comment_id_key_2"
adminkey: "comment_adminkey_2"
reply_to: null
@@ -561,16 +574,16 @@
- model : cm.comment
pk: 3
fields:
- created: "2009-02-13 04:01:13"
+ created: "2009-02-13 04:01:13"
modified: "2009-02-13 04:01:13"
- start_wrapper: 0
+ start_wrapper: 0
end_wrapper: 0
- start_offset: 1
+ start_offset: 1
end_offset: 11
- title: "comment 3"
- content: "comment 3 content"
- content_html: "<p>comment 3 content</p>"
- key: "comment_key_3"
+ title: "comment 3"
+ content: "comment 3 content"
+ content_html: "<p>comment 3 content</p>"
+ key: "comment_key_3"
id_key: "comment_id_key_3"
adminkey: "comment_adminkey_3"
reply_to: null
@@ -582,12 +595,12 @@
- model : cm.comment
pk: 4
fields:
- created: "2009-02-13 04:01:13"
+ created: "2009-02-13 04:01:13"
modified: "2009-02-13 04:01:13"
- title: "comment 4"
- content: "comment 4 content"
- content_html: "<p>comment 4 content</p>"
- key: "comment_key_4"
+ title: "comment 4"
+ content: "comment 4 content"
+ content_html: "<p>comment 4 content</p>"
+ key: "comment_key_4"
id_key: "comment_id_key_4"
adminkey: "comment_adminkey_4"
reply_to: 3
@@ -599,35 +612,32 @@
- model : cm.activity
pk: 1
fields:
- created: "2009-01-13 04:01:13"
- text: 1
+ created: "2009-01-13 04:01:13"
+ text: 1
originator_user: 1
type: 'text_view'
- model : cm.activity
pk: 2
fields:
- created: "2009-01-13 04:31:13"
- text: 1
+ created: "2009-01-13 04:31:13"
+ text: 1
originator_user: 1
type: 'text_view'
-
+
- model : cm.activity
pk: 3
fields:
- created: "2009-01-02 04:31:13"
- text: 1
- originator_user: 1
- type: 'text_view'
-
-
-- model : cm.activity
- pk: 4
- fields:
- created: "2009-01-31 04:31:13"
- text: 1
+ created: "2009-01-02 04:31:13"
+ text: 1
originator_user: 1
type: 'text_view'
-
\ No newline at end of file
+- model : cm.activity
+ pk: 4
+ fields:
+ created: "2009-01-31 04:31:13"
+ text: 1
+ originator_user: 1
+ type: 'text_view'
--- a/src/cm/tests/test_security.py Tue May 06 15:55:24 2014 +0200
+++ b/src/cm/tests/test_security.py Fri May 09 16:52:14 2014 +0200
@@ -1,7 +1,7 @@
from django.test import TestCase
from django.test.client import Client
from django.core import management
-from django.core.cache import cache
+
from cm.models import *
from cm.security import *
@@ -12,7 +12,7 @@
self.user = user
class SecurityTest(TestCase):
- fixtures = ['initial_data', 'roles_generic','test_content']
+ fixtures = ['initial_data','roles_generic','test_content']
def test_access_rights(self):
# anon user sees no text
@@ -53,7 +53,6 @@
c2.save()
c3.state = 'approved'
c3.save()
- cache.clear()
self.assertFalse(has_own_perm(FalseRequest(user3), "can_edit_comment" + "_own", text2, c3),'CANNOT edit own comment (there is a reply)')
self.assertTrue(has_own_perm(FalseRequest(user2), "can_edit_comment" + "_own", text2, c2),"CAN edit own comment (is moderator)")
@@ -78,4 +77,4 @@
self.assertFalse(has_own_perm(FalseRequest(user3), "can_edit_comment" + "_own", text2, c3),'CANNOT edit own comment (there is a reply)')
self.assertTrue(has_perm(FalseRequest(user2), "can_edit_comment", text2),"CAN edit other's comment (moderator)")
-
+
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/cm/wsgi.py Fri May 09 16:52:14 2014 +0200
@@ -0,0 +1,11 @@
+import os
+import sys
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'cm.settings'
+
+path = os.environ['PROJECT_PATH']
+if path not in sys.path:
+ sys.path.append(path)
+
+import django.core.handlers.wsgi
+app = django.core.handlers.wsgi.WSGIHandler()
--- a/test-suite/start-test-suite.sh Tue May 06 15:55:24 2014 +0200
+++ b/test-suite/start-test-suite.sh Fri May 09 16:52:14 2014 +0200
@@ -1,13 +1,36 @@
#!/bin/bash
-echo "Starting test server"
TESTSERVER_LOGS="/tmp/django_test_server_logs.`date +%F_%T`"
-cd ..
-nohup ./bin/django testserver --noinput localhost:8000 initial_data roles_generic test_suite > $TESTSERVER_LOGS 2>&1 &
-TESTSERVER_PID=$!
-cd "test-suite"
+if [ -z "$WORKSPACE_INFO" ]; then
+ WORKSPACE_INFO="workspace.info.js"
+fi
+
+WORKSPACE_URL_LINE=`grep -v '^[[:space:]]*//' "$WORKSPACE_INFO" | grep WORKSPACE_URL | head -n 1`
+echo "Workspace_url_line : $WORKSPACE_URL_LINE"
+
+SERVER_IP=`echo "$WORKSPACE_URL_LINE" | sed "s|^.*http://\([-._[:alnum:]]*\).*$|\1|"`
+if [ "$SERVER_IP" = "$WORKSPACE_URL_LINE" ]; then
+ echo "No ip found in WORKSPACE_URL, using localhost"
+ SERVER_IP="127.0.0.1"
+fi
+
+SERVER_PORT=`echo "$WORKSPACE_URL_LINE" | sed "s|^.*http://[-._[:alnum:]]*:\([0-9]*\).*$|\1|"`
+if [ "$SERVER_PORT" = "$WORKSPACE_URL_LINE" ]; then
+ echo "No port found in WORKSPACE_URL, using 80"
+ SERVER_PORT="80"
+fi
+
+echo "Test server : $SERVER_IP:$SERVER_PORT"
+
+if [ -z "$TESTSERVER_STARTED" ]; then
+ echo "Starting test server"
+ cd ..
+ nohup ./bin/django testserver --noinput localhost:$SERVER_PORT initial_data roles_generic test_suite > $TESTSERVER_LOGS 2>&1 &
+ TESTSERVER_PID=$!
+ cd "test-suite"
+fi
# Exports browsers _BIN variables for karma
export CHROME_BIN=`which chromium`
@@ -44,9 +67,6 @@
TESTSERVER_LOOP_WAIT=5
TESTSERVER_WAIT_LOOP_NB=5
-SERVER_IP=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://\([-._[:alnum:]]*\):.*$|\1|"`
-SERVER_PORT=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://[-._[:alnum:]]*:\([0-9]*\)/.*$|\1|"`
-
if [[ -x `which nc` ]]; then
SERVER_TEST_CMD="nc -w $CONNECTION_TIMEOUT -z $SERVER_IP $SERVER_PORT"
elif [[ -x `which curl` ]]; then
@@ -61,14 +81,16 @@
echo "No http tool available so blindly waiting $TESTSERVER_START_WAIT seconds to let test server start"
sleep $TESTSERVER_START_WAIT
else
+ SERVER_STARTED=false
for i in $(seq 1 $TESTSERVER_WAIT_LOOP_NB); do
echo "and waiting $TESTSERVER_LOOP_WAIT seconds"
sleep $TESTSERVER_LOOP_WAIT
if $SERVER_TEST_CMD; then
+ SERVER_STARTED=true
break
fi
done
- if [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
+ if ! $SERVER_STARTED && [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
echo "timeouted waiting for test server $SERVER_IP:$SERVER_PORT to start"
exit 1
fi
@@ -78,11 +100,14 @@
echo "$KARMA start $@"
"$KARMA" start $@
-read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N) " -n 1 -r -t 5
-echo # (optional) move to a new line
-if [[ $REPLY =~ ^[Yy]$ ]]; then
- exit 0
+if [ -z "$TESTSERVER_STARTED" ]; then
+ read -p "Keep testserver (PID $TESTSERVER_PID) running? (y/N) " -n 1 -r -t 5
+ echo # (optional) move to a new line
+
+ if [[ $REPLY =~ ^[Yy]$ ]]; then
+ exit 0
+ fi
+
+ kill $TESTSERVER_PID
fi
-
-kill $TESTSERVER_PID
--- a/test-suite/tests/012_comt-admin-text-list.js Tue May 06 15:55:24 2014 +0200
+++ b/test-suite/tests/012_comt-admin-text-list.js Fri May 09 16:52:14 2014 +0200
@@ -57,9 +57,9 @@
for (var i=4; i--;) {
test_text ('a.main_object_title:eq('+i+')', C.TEXTS[2]['#id_title']);
- test_match ('.tag_list:eq('+i+')', /tags: test_text Text Troisième /);
- test_text ('.tag_list:eq('+i+') a:eq(0)[href="?tag_selected=test_text"]', 'test_text');
- test_text ('.tag_list:eq('+i+') a:eq(1)[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième');
+ test_match ('.tag_list:eq('+i+')', /tags:(?:\sText Troisième|\stest_text){2}\s/);
+ test_text ('.tag_list:eq('+i+') a[href="?tag_selected=test_text"]', 'test_text');
+ test_text ('.tag_list:eq('+i+') a[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième');
test_text ('#text .hidden-text-actions:eq('+i+') a:eq(0)[href^="/text/"][href$="/view/"]', 'View');
test_text ('#text .hidden-text-actions:eq('+i+') a:eq(1)[href^="/text/"][href$="/edit/"]', 'Edit');
test_text ('#text .hidden-text-actions:eq('+i+') a:eq(2)[href="#"][id*="text-delete-"]', 'Delete');
--- a/test-suite/tests/013_comt-admin-user-list.js Tue May 06 15:55:24 2014 +0200
+++ b/test-suite/tests/013_comt-admin-user-list.js Fri May 09 16:52:14 2014 +0200
@@ -1,7 +1,7 @@
suite ('comt logged admin user list', function () {
- this.timeout(20000);
+ this.timeout(100000);
suite ('people list page conformity', function () {
test_page_loading ('/user/', 'People\' list\n - '+C['#id_workspace_name']);