--- a/entities/adapters.py Thu Jun 10 16:57:02 2010 +0200
+++ b/entities/adapters.py Thu Jun 10 18:28:12 2010 +0200
@@ -29,7 +29,7 @@
from cubicweb.view import EntityAdapter, implements_adapter_compat
from cubicweb.selectors import implements, relation_possible
-from cubicweb.interfaces import IDownloadable, ITree
+from cubicweb.interfaces import IDownloadable, ITree, IProgress, IMileStone
class IEmailableAdapter(EntityAdapter):
@@ -327,3 +327,109 @@
path.reverse()
return path
+
+class IProgressAdapter(EntityAdapter):
+ """something that has a cost, a state and a progression.
+
+ You should at least override progress_info an in_progress methods on concret
+ implementations.
+ """
+ __regid__ = 'IProgress'
+ __select__ = implements(IProgress) # XXX for bw compat, should be abstract
+
+ @property
+ @implements_adapter_compat('IProgress')
+ def cost(self):
+ """the total cost"""
+ return self.progress_info()['estimated']
+
+ @property
+ @implements_adapter_compat('IProgress')
+ def revised_cost(self):
+ return self.progress_info().get('estimatedcorrected', self.cost)
+
+ @property
+ @implements_adapter_compat('IProgress')
+ def done(self):
+ """what is already done"""
+ return self.progress_info()['done']
+
+ @property
+ @implements_adapter_compat('IProgress')
+ def todo(self):
+ """what remains to be done"""
+ return self.progress_info()['todo']
+
+ @implements_adapter_compat('IProgress')
+ def progress_info(self):
+ """returns a dictionary describing progress/estimated cost of the
+ version.
+
+ - mandatory keys are (''estimated', 'done', 'todo')
+
+ - optional keys are ('notestimated', 'notestimatedcorrected',
+ 'estimatedcorrected')
+
+ 'noestimated' and 'notestimatedcorrected' should default to 0
+ 'estimatedcorrected' should default to 'estimated'
+ """
+ raise NotImplementedError
+
+ @implements_adapter_compat('IProgress')
+ def finished(self):
+ """returns True if status is finished"""
+ return not self.in_progress()
+
+ @implements_adapter_compat('IProgress')
+ def in_progress(self):
+ """returns True if status is not finished"""
+ raise NotImplementedError
+
+ @implements_adapter_compat('IProgress')
+ def progress(self):
+ """returns the % progress of the task item"""
+ try:
+ return 100. * self.done / self.revised_cost
+ except ZeroDivisionError:
+ # total cost is 0 : if everything was estimated, task is completed
+ if self.progress_info().get('notestimated'):
+ return 0.
+ return 100
+
+ @implements_adapter_compat('IProgress')
+ def progress_class(self):
+ return ''
+
+
+class IMileStoneAdapter(IProgressAdapter):
+ __regid__ = 'IMileStone'
+ __select__ = implements(IMileStone) # XXX for bw compat, should be abstract
+
+ parent_type = None # specify main task's type
+
+ @implements_adapter_compat('IMileStone')
+ def get_main_task(self):
+ """returns the main ITask entity"""
+ raise NotImplementedError
+
+ @implements_adapter_compat('IMileStone')
+ def initial_prevision_date(self):
+ """returns the initial expected end of the milestone"""
+ raise NotImplementedError
+
+ @implements_adapter_compat('IMileStone')
+ def eta_date(self):
+ """returns expected date of completion based on what remains
+ to be done
+ """
+ raise NotImplementedError
+
+ @implements_adapter_compat('IMileStone')
+ def completion_date(self):
+ """returns date on which the subtask has been completed"""
+ raise NotImplementedError
+
+ @implements_adapter_compat('IMileStone')
+ def contractors(self):
+ """returns the list of persons supposed to work on this task"""
+ raise NotImplementedError
--- a/web/application.py Thu Jun 10 16:57:02 2010 +0200
+++ b/web/application.py Thu Jun 10 18:28:12 2010 +0200
@@ -15,9 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""CubicWeb web client application object
+"""CubicWeb web client application object"""
-"""
from __future__ import with_statement
__docformat__ = "restructuredtext en"
--- a/web/views/ibreadcrumbs.py Thu Jun 10 16:57:02 2010 +0200
+++ b/web/views/ibreadcrumbs.py Thu Jun 10 18:28:12 2010 +0200
@@ -15,9 +15,8 @@
#
# You should have received a copy of the GNU Lesser General Public License along
# with CubicWeb. If not, see <http://www.gnu.org/licenses/>.
-"""navigation components definition for CubicWeb web client
+"""breadcrumbs components definition for CubicWeb web client"""
-"""
__docformat__ = "restructuredtext en"
_ = unicode
--- a/web/views/iprogress.py Thu Jun 10 16:57:02 2010 +0200
+++ b/web/views/iprogress.py Thu Jun 10 18:28:12 2010 +0200
@@ -25,120 +25,12 @@
from logilab.mtconverter import xml_escape
from cubicweb.utils import make_uid
-from cubicweb.selectors import implements, adaptable
-from cubicweb.interfaces import IProgress, IMileStone
+from cubicweb.selectors import adaptable
from cubicweb.schema import display_name
-from cubicweb.view import EntityView, EntityAdapter, implements_adapter_compat
+from cubicweb.view import EntityView
from cubicweb.web.views.tableview import EntityAttributesTableView
-class IProgressAdapter(EntityAdapter):
- """something that has a cost, a state and a progression.
-
- You should at least override progress_info an in_progress methods on concret
- implementations.
- """
- __regid__ = 'IProgress'
- __select__ = implements(IProgress) # XXX for bw compat, should be abstract
-
- @property
- @implements_adapter_compat('IProgress')
- def cost(self):
- """the total cost"""
- return self.progress_info()['estimated']
-
- @property
- @implements_adapter_compat('IProgress')
- def revised_cost(self):
- return self.progress_info().get('estimatedcorrected', self.cost)
-
- @property
- @implements_adapter_compat('IProgress')
- def done(self):
- """what is already done"""
- return self.progress_info()['done']
-
- @property
- @implements_adapter_compat('IProgress')
- def todo(self):
- """what remains to be done"""
- return self.progress_info()['todo']
-
- @implements_adapter_compat('IProgress')
- def progress_info(self):
- """returns a dictionary describing progress/estimated cost of the
- version.
-
- - mandatory keys are (''estimated', 'done', 'todo')
-
- - optional keys are ('notestimated', 'notestimatedcorrected',
- 'estimatedcorrected')
-
- 'noestimated' and 'notestimatedcorrected' should default to 0
- 'estimatedcorrected' should default to 'estimated'
- """
- raise NotImplementedError
-
- @implements_adapter_compat('IProgress')
- def finished(self):
- """returns True if status is finished"""
- return not self.in_progress()
-
- @implements_adapter_compat('IProgress')
- def in_progress(self):
- """returns True if status is not finished"""
- raise NotImplementedError
-
- @implements_adapter_compat('IProgress')
- def progress(self):
- """returns the % progress of the task item"""
- try:
- return 100. * self.done / self.revised_cost
- except ZeroDivisionError:
- # total cost is 0 : if everything was estimated, task is completed
- if self.progress_info().get('notestimated'):
- return 0.
- return 100
-
- @implements_adapter_compat('IProgress')
- def progress_class(self):
- return ''
-
-
-class IMileStoneAdapter(IProgressAdapter):
- __regid__ = 'IMileStone'
- __select__ = implements(IMileStone) # XXX for bw compat, should be abstract
-
- parent_type = None # specify main task's type
-
- @implements_adapter_compat('IMileStone')
- def get_main_task(self):
- """returns the main ITask entity"""
- raise NotImplementedError
-
- @implements_adapter_compat('IMileStone')
- def initial_prevision_date(self):
- """returns the initial expected end of the milestone"""
- raise NotImplementedError
-
- @implements_adapter_compat('IMileStone')
- def eta_date(self):
- """returns expected date of completion based on what remains
- to be done
- """
- raise NotImplementedError
-
- @implements_adapter_compat('IMileStone')
- def completion_date(self):
- """returns date on which the subtask has been completed"""
- raise NotImplementedError
-
- @implements_adapter_compat('IMileStone')
- def contractors(self):
- """returns the list of persons supposed to work on this task"""
- raise NotImplementedError
-
-
class ProgressTableView(EntityAttributesTableView):
"""The progress table view is able to display progress information
of any object implement IMileStone.