backport missing stuff :(
authorSylvain <syt@logilab.fr>
Thu, 18 Dec 2008 17:45:27 +0100
changeset 1 92a91e7a8936
parent 0 eaa65c0bdafb
child 2 25144b2612d1
backport missing stuff :(
MANIFEST.in
__pkginfo__.py
debian/changelog
debian/control
entities.py
i18n/en.po
i18n/fr.po
test/test_fresh.py
views.py
views/__init__.py
views/accounting.py
views/actions.py
views/controllers.py
--- a/MANIFEST.in	Thu Dec 18 17:09:14 2008 +0100
+++ b/MANIFEST.in	Thu Dec 18 17:45:27 2008 +0100
@@ -1,4 +1,5 @@
 include *.py
 
+recursive-include views *.py
 recursive-include i18n *.pot *.po
-recursive-include migration *.sql *.py 
+recursive-include migration *.sql *.py depends.map
--- a/__pkginfo__.py	Thu Dec 18 17:09:14 2008 +0100
+++ b/__pkginfo__.py	Thu Dec 18 17:45:27 2008 +0100
@@ -34,15 +34,9 @@
 
 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, 'views'), listdir('views')],
         [join(THIS_TEMPLATE_DIR, 'migration'), listdir('migration')],
         ]
 except OSError:
--- a/debian/changelog	Thu Dec 18 17:09:14 2008 +0100
+++ b/debian/changelog	Thu Dec 18 17:45:27 2008 +0100
@@ -1,6 +1,18 @@
+cubicweb-fresh (0.1.2-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Adrien.DiMascio <Adrien.DiMascio@logilab.fr>  Tue, 29 Jul 2008 19:35:09 +0200
+
+cubicweb-fresh (0.1.1-1) unstable; urgency=low
+
+  * new upstream release
+
+ -- Adrien.DiMascio <Adrien.DiMascio@logilab.fr>  Mon, 28 Jul 2008 18:57:46 +0200
+
 cubicweb-fresh (0.1.0-1) unstable; urgency=low
 
   * initial release
 
- -- 
+ -- Adrien.DiMascio <Adrien.DiMascio@logilab.fr>  Tue, 10 Jun 2008 16:14:04 +0200
 
--- a/debian/control	Thu Dec 18 17:09:14 2008 +0100
+++ b/debian/control	Thu Dec 18 17:45:27 2008 +0100
@@ -9,8 +9,8 @@
 
 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
+Conflicts: cubicweb-fresh, erudi-fresh-client, erudi-fresh-server, erudi-fresh-comp
+Replaces: cubicweb-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
--- a/entities.py	Thu Dec 18 17:09:14 2008 +0100
+++ b/entities.py	Thu Dec 18 17:45:27 2008 +0100
@@ -14,3 +14,11 @@
     __rtags__ = {
         'paid_by' : 'primary',
         }
+
+    @property
+    def workcase(self):
+        rql = 'Any R WHERE E has_lines EL, EL eid %(el)s, E spent_for W, W ref R'
+        rset = self.req.execute(rql, {'el': self.eid})
+        if rset:
+            return rset[0][0]
+        return None
--- a/i18n/en.po	Thu Dec 18 17:09:14 2008 +0100
+++ b/i18n/en.po	Thu Dec 18 17:45:27 2008 +0100
@@ -1,7 +1,36 @@
 msgid ""
 msgstr ""
-"Content-Type: text/plain; charset=ISO-8859-1\n"
+"Project-Id-Version: 2.0\n"
+"POT-Creation-Date: 2006-01-12 17:35+CET\n"
+"PO-Revision-Date: 2008-06-09 17:56+0200\n"
+"Last-Translator: Logilab\n"
+"Language-Team: English <devel@logilab.fr.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: pygettext.py 1.5\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
+msgid "accounting entry view"
+msgstr "accounting entry view"
+
+msgid "actions_accaction"
+msgstr "action which generates accounting entries"
+
+# add related box generated message
+msgid "actions_accaction_description"
+msgstr "action which generates accounting entries"
+
+msgid "generate accounting entries"
+msgstr "generate accounting entries"
+
+# schema pot file, generated on 2008-04-14 11:36:25
+#
+# singular and plural forms for each entity type
+# subject and object forms for each relation type
+# (no object form for final relation types)
+msgid "spent_for"
+msgstr "spent for"
+
+msgid "spent_for_object"
+msgstr "was paid"
--- a/i18n/fr.po	Thu Dec 18 17:09:14 2008 +0100
+++ b/i18n/fr.po	Thu Dec 18 17:45:27 2008 +0100
@@ -2,12 +2,35 @@
 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"
+"PO-Revision-Date: 2008-06-09 17:56+0200\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-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 "Generated-By: pygettext.py 1.5\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
+msgid "accounting entry view"
+msgstr "écriture comptabilité"
+
+msgid "actions_accaction"
+msgstr "action permettant de générer les écritures"
+
+# add related box generated message
+msgid "actions_accaction_description"
+msgstr "action permettant de générer les écritures"
+
+msgid "generate accounting entries"
+msgstr "générer les écritures comptables"
+
+# schema pot file, generated on 2008-04-14 11:36:25
+#
+# singular and plural forms for each entity type
+# subject and object forms for each relation type
+# (no object form for final relation types)
+msgid "spent_for"
+msgstr "dépensé pour"
+
+msgid "spent_for_object"
+msgstr "s'est fait payer"
--- a/test/test_fresh.py	Thu Dec 18 17:09:14 2008 +0100
+++ b/test/test_fresh.py	Thu Dec 18 17:45:27 2008 +0100
@@ -1,16 +1,14 @@
 """template automatic tests"""
 
-from logilab.common.testlib import TestCase, unittest_main
+from logilab.common.testlib import unittest_main
 
-class DefaultTC(TestCase):
-    def test_something(self):
-        self.skip('this component has no test')
+from cubicweb.devtools.htmlparser import SaxOnlyValidator
+from cubicweb.devtools.testlib import AutomaticWebTest
 
-## uncomment the import if you want to activate automatic test for your
-## template
-
-# from cubicweb.devtools.testlib import AutomaticWebTest
-
+AutomaticWebTest.validators.update({
+    'accexpense': SaxOnlyValidator,
+    'accentry': SaxOnlyValidator,
+    })
 
 if __name__ == '__main__':
     unittest_main()
--- a/views.py	Thu Dec 18 17:09:14 2008 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-"""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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/__init__.py	Thu Dec 18 17:45:27 2008 +0100
@@ -0,0 +1,1 @@
+"""template-specific forms/views/actions/components"""
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/accounting.py	Thu Dec 18 17:45:27 2008 +0100
@@ -0,0 +1,69 @@
+"""accounting views for fresh template
+
+:organization: Logilab
+:copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
+__docformat__ = "restructuredtext en"
+
+
+from logilab.mtconverter import html_escape
+
+from cubicweb.common.view import EntityView
+
+
+class ExpenseAccountingXmlView(EntityView):
+    id = 'accexpense'
+    title = _('accounting entry view')
+    templatable = False
+    content_type = 'text/xml'
+    accepts = ('Expense',)
+
+    def cell_call(self, row, col):
+        entity = self.entity(row, col)
+        self.wview('accentry', entity.related('has_lines'))
+
+
+class ExpenseLineAccountingEntryXmlView(EntityView):
+    id = 'accentry'
+    title = _('accounting entry view')
+    templatable = False
+    content_type = 'text/xml'
+    accepts = ('ExpenseLine',)
+        
+    def call(self):
+        """display a list of entities by calling their <item_vid> view
+        """
+        self.w(u'<?xml version="1.0" encoding="%s"?>\n' % self.req.encoding)
+        self.w(u'<ecritures>\n')
+        for i in xrange(self.rset.rowcount):
+            self.cell_call(i, 0)
+        self.w(u'</ecritures>\n')
+    
+    def cell_call(self, row, col):
+        entity = self.complete_entity(row, col)
+        self.w(u'  <ecriture date="%s">\n' % entity.diem.strftime('%Y-%m-%d'))
+        self.w(u'    <libelle>%s</libelle>\n' % html_escape(entity.dc_long_title()))
+        amount = int(entity.euro_amount()*100) / 100.0
+        taxes = int(entity.taxes*100) / 100.0
+        self.w(u'    <credit compte="%s" montant="%.2f" />\n' % (
+            entity.paid_by[0].account, amount))
+        if entity.taxes:
+            # XXX hardcoded account for VAT
+            self.w(u'    <debit compte="44566" montant="%.2f" />\n' % entity.taxes)
+        taxfree = amount - taxes
+        accounts = list(entity.paid_for)
+        debit_quotient = int(taxfree*100) / len(accounts)
+        debit_remainder = int(taxfree*100) % len(accounts)
+        for account in accounts:
+            if debit_remainder > 0:
+                debit = (debit_quotient + 1) / 100.0
+                debit_remainder -= 1
+            else:
+                debit = debit_quotient / 100.0
+            self.w(u'    <debit compte="%s" montant="%.2f" />\n' %
+                   (account.account, debit))
+        if entity.workcase:
+            self.w(u'    <groupe>%s</groupe>\n' % entity.workcase)
+        self.w(u'  </ecriture>\n')
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/actions.py	Thu Dec 18 17:45:27 2008 +0100
@@ -0,0 +1,19 @@
+"""specific actions for fresh template
+
+:organization: Logilab
+:copyright: 2008 LOGILAB S.A. (Paris, FRANCE), all rights reserved.
+:contact: http://www.logilab.fr/ -- mailto:contact@logilab.fr
+"""
+__docformat__ = "restructuredtext en"
+
+from cubicweb.web.action import EntityAction
+
+class AccountingAction(EntityAction):
+    accepts = ('Expense',)
+    id = 'accaction'
+    title = _('generate accounting entries')
+    
+    def url(self):
+        entity = self.entity(0, 0)
+        return entity.build_url(vid='accexpense')
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/views/controllers.py	Thu Dec 18 17:45:27 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