turn into a cube
authorSylvain <syt@logilab.fr>
Thu, 18 Dec 2008 17:09:14 +0100
changeset 0 eaa65c0bdafb
child 1 92a91e7a8936
turn into a cube
MANIFEST.in
__init__.py
__pkginfo__.py
debian/changelog
debian/compat
debian/control
debian/copyright
debian/cubicweb-fresh.prerm
debian/rules
entities.py
i18n/en.po
i18n/fr.po
migration/postcreate.py
migration/precreate.py
schema.py
setup.py
test/data/bootstrap_cubes
test/test_fresh.py
views.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MANIFEST.in	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,4 @@
+include *.py
+
+recursive-include i18n *.pot *.po
+recursive-include migration *.sql *.py 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/__init__.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,4 @@
+"""cubicweb-fresh application package
+
+expense reporting application
+"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/__pkginfo__.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,55 @@
+# pylint: disable-msg=W0622
+"""cubicweb-fresh application packaging information"""
+
+distname = 'cubicweb-fresh'
+
+numversion = (0, 1, 0)
+version = '.'.join(str(num) for num in numversion)
+
+license = 'LCL'
+copyright = '''Copyright (c) 2008 LOGILAB S.A. (Paris, FRANCE).
+http://www.logilab.fr/ -- mailto:contact@logilab.fr'''
+
+author = 'Logilab'
+author_email = 'contact@logilab.fr'
+
+short_desc = 'expense reporting application'
+long_desc = '''expense reporting application'''
+
+from os import listdir as _listdir
+from os.path import join, isdir
+
+web, ftp = '', ''
+
+pyversions = ['2.4']
+
+#from cubicweb.devtools.pkginfo import get_distutils_datafiles
+TEMPLATES_DIR = join('share', 'cubicweb', 'cubes')
+THIS_TEMPLATE_DIR = join(TEMPLATES_DIR, 'fresh')
+
+def listdir(dirpath):
+    return [join(dirpath, fname) for fname in _listdir(dirpath)
+            if fname[0] != '.' and not fname.endswith('.pyc')
+            and not fname.endswith('~')]
+
+try:
+    data_files = [
+        # common files
+        [THIS_TEMPLATE_DIR, [fname for fname in glob('*.py') if fname != 'setup.py']],
+
+        # client (web) files
+        [join(THIS_TEMPLATE_DIR, 'i18n'),  listdir('i18n')],
+        # Note: here, you'll need to add views' subdirectories if you want
+        # them to be included in the debian package
+        
+        # server files
+        [join(THIS_TEMPLATE_DIR, 'migration'), listdir('migration')],
+        ]
+except OSError:
+    # we are in an installed directory
+    pass
+
+
+cube_eid = None # <=== FIXME if you need direct bug-subscription
+__use__ = ('expense', 'workcase')
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/changelog	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,6 @@
+cubicweb-fresh (0.1.0-1) unstable; urgency=low
+
+  * initial release
+
+ -- 
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/compat	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,1 @@
+5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/control	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,19 @@
+Source: cubicweb-fresh
+Section: web
+Priority: optional
+Maintainer: Logilab Packaging Team <contact@logilab.fr>
+Uploaders: Sylvain Thenault <sylvain.thenault@logilab.fr> 
+Build-Depends: debhelper (>= 5.0.37.1), python (>=2.4), python-dev (>=2.4)
+Standards-Version: 3.8.0
+
+
+Package: cubicweb-fresh
+Architecture: all
+Conflicts: erudi-fresh, erudi-fresh-client, erudi-fresh-server, erudi-fresh-comp
+Replaces: erudi-fresh, erudi-fresh-client, erudi-fresh-server, erudi-fresh-comp
+Depends: cubicweb-common (>= 2.99.0)
+Description: expense reporting application
+ CubicWeb is a entities / relations bases knowledge management system
+ developed at Logilab.
+ .
+ expense reporting application
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/copyright	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,14 @@
+This package was debianized by Logilab <contact@logilab.fr>
+
+Upstream Author: 
+
+  Logilab <contact@logilab.fr>
+
+Copyright:
+
+Copyright (c) 2008 LOGILAB S.A. (Paris, FRANCE).
+http://www.logilab.fr/ -- mailto:contact@logilab.fr
+
+Logilab Closed source License. This code is *NOT* open-source. Usage of this
+code is subject to a licence agreement. If you want to use it, you should
+contact logilab's sales service at commercial@logilab.fr .
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/cubicweb-fresh.prerm	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,27 @@
+#!/bin/sh -e
+
+delete_pyo_pyc () {
+  find /usr/share/cubicweb/cubes/fresh -name "*.pyc" | xargs rm -f
+  find /usr/share/cubicweb/cubes/fresh -name "*.pyo" | xargs rm -f
+}
+
+
+case "$1" in
+    failed-upgrade|abort-install|abort-upgrade|disappear)
+    ;;
+    upgrade)
+    delete_pyo_pyc
+    ;;
+    remove)
+    delete_pyo_pyc
+    ;;
+    purge)
+    ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+esac
+
+#DEBHELPER#
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/debian/rules	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,51 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+build: build-stamp
+build-stamp: 
+	dh_testdir
+	python setup.py -q build
+	touch build-stamp
+
+clean: 
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+	rm -rf build
+	find . -name "*.pyc" | xargs rm -f
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs -i
+	python setup.py -q install --no-compile --prefix=debian/cubicweb-fresh/usr/
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+	dh_testdir
+	dh_testroot
+	dh_install -i
+	dh_installchangelogs -i
+	dh_installexamples -i
+	dh_installdocs -i
+	dh_installman -i
+	dh_link -i
+	dh_compress -i -X.py -X.ini -X.xml -Xtest
+	dh_fixperms -i
+	dh_installdeb -i
+	dh_gencontrol -i 
+	dh_md5sums -i
+	dh_builddeb -i
+
+
+# Build architecture-dependent files here.
+binary-arch: 
+
+binary: binary-indep 
+.PHONY: build clean binary-arch binary-indep binary
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/entities.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,16 @@
+"""this contains the template-specific entities' classes"""
+
+from eexpense.entities import Expense as BaseExpense, ExpenseLine as BaseExpenseLine
+
+class Expense(BaseExpense):
+
+    __rtags__ = {'spent_for' : 'primary'}
+    widgets = {'spent_for' : 'RestrictedAutoCompletionWidget'}
+    autocomplete_initfuncs = {'spent_for' : 'get_concerned_by'}
+    
+
+class ExpenseLine(BaseExpenseLine):
+
+    __rtags__ = {
+        'paid_by' : 'primary',
+        }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i18n/en.po	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,7 @@
+msgid ""
+msgstr ""
+"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: pygettext.py 1.5\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i18n/fr.po	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,13 @@
+msgid ""
+msgstr ""
+"Project-Id-Version: 2.0\n"
+"POT-Creation-Date: 2006-01-12 17:35+CET\n"
+"PO-Revision-Date: 2008-02-15 12:55+0100\n"
+"Last-Translator: Logilab\n"
+"Language-Team: French <devel@logilab.fr.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=ISO-8859-15\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: pygettext.py 1.5\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/postcreate.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# postcreate script. You could setup a workflow here for example
+
+for login in (u'alf', u'syt', u'nico', u'jphc', u'ocy', u'auc', u'katia',
+              u'graz', u'dede', u'juj', u'ludal', u'steph', u'arthur',
+              u'david', u'joel', u'gaston', u'adim'):
+    rql('INSERT EUser E: E login %(login)s, E upassword %(login)s, E in_group G '
+        'WHERE G name "users"', {'login' : login})
+    rql('INSERT PaidByAccount P: P label %(label)s, P associated_to U WHERE U login %(login)s',
+        {'label' : u"refund account - %s" % login, 'login': login})
+    rql('INSERT PaidForAccount P: P label %(label)s', {'label' : u"charge account - %s" % login})
+
+
+for label in (u'Logilab - CB Nicolas', u'Logilab - CB Alexandre', u'Logilab - CB Olivier',
+              u'Logilab - Esp├Ęces'):
+    rql('INSERT PaidByAccount P: P label %(label)s', {'label' : label})
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/migration/precreate.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,3 @@
+# Instructions here will be read before reading the schema
+# You could create your own groups here, like in :
+#   add_entity('EGroup', name=u'mygroup')
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/schema.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,4 @@
+# template's specific schema
+Expense = import_erschema('Expense')
+Expense.add_relation(SubjectRelation('Workcase', cardinality='?*'), name='spent_for')
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/setup.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+# pylint: disable-msg=W0404,W0622,W0704,W0613,W0152
+# Copyright (c) 2003-2004 LOGILAB S.A. (Paris, FRANCE).
+# http://www.logilab.fr/ -- mailto:contact@logilab.fr
+#
+# This program is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc.,
+# 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+""" Generic Setup script, takes package info from __pkginfo__.py file """
+
+import os
+import sys
+import shutil
+from distutils.core import setup
+from distutils import command
+from distutils.command import install_lib
+from os.path import isdir, exists, join, walk
+
+# import required features
+from __pkginfo__ import distname, version, license, short_desc, long_desc, \
+     web, author, author_email
+try:
+    from __pkginfo__ import scripts
+except ImportError:
+    scripts = []
+try:
+    from __pkginfo__ import data_files
+except ImportError:
+    data_files = None
+    
+def ensure_scripts(linux_scripts):
+    """creates the proper script names required for each platform
+    (taken from 4Suite)
+    """
+    from distutils import util
+    if util.get_platform()[:3] == 'win':
+        scripts_ = [script + '.bat' for script in linux_scripts]
+    else:
+        scripts_ = linux_scripts
+    return scripts_
+
+def install(**kwargs):
+    """setup entry point"""
+    return setup(name=distname,
+                 version=version,
+                 license =license,
+                 description=short_desc,
+                 long_description=long_desc,
+                 author=author,
+                 author_email=author_email,
+                 url=web,
+                 scripts=ensure_scripts(scripts),
+                 data_files=data_files,
+                 **kwargs)
+            
+if __name__ == '__main__' :
+    install()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/data/bootstrap_cubes	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,1 @@
+fresh
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/test_fresh.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,16 @@
+"""template automatic tests"""
+
+from logilab.common.testlib import TestCase, unittest_main
+
+class DefaultTC(TestCase):
+    def test_something(self):
+        self.skip('this component has no test')
+
+## uncomment the import if you want to activate automatic test for your
+## template
+
+# from cubicweb.devtools.testlib import AutomaticWebTest
+
+
+if __name__ == '__main__':
+    unittest_main()
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views.py	Thu Dec 18 17:09:14 2008 +0100
@@ -0,0 +1,14 @@
+"""Specific controllers for CRM.
+
+:organization: Logilab
+:copyright: 2003-2007 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
+__docformat__ = "restructuredtext en"
+
+from cubicweb.web.views.basecontrollers import JSonController
+
+def js_get_concerned_by(self):
+    return self.req.execute('DISTINCT Any W,R WHERE W ref R ORDERBY R').rows
+
+JSonController.js_get_concerned_by = js_get_concerned_by