[Cubicweb] Ticket / IProgressAdapter

Carlos Balderas carlos.balderas at gmail.com
Fri Sep 10 15:02:54 CEST 2010


Thank you Syt.


I just made a little changes on progress_info. Here it is.

def progress_info(self):

        """returns a dictionary describing load and progress of the
ticket"""

        return {'notestimated': 0,
                'estimated': self.entity.load,
                'done': self.entity.load - self.entity.load_left,
                'todo': self.entity.load_left}


If you find this correct, let know to send you a bundle for the repository.

=)

Carlos Balderas


On Fri, Sep 10, 2010 at 1:46 AM, Sylvain Thénault <
sylvain.thenault at logilab.fr> wrote:

> On 09 septembre 21:42, Carlos Balderas wrote:
> > Hello, list
>
> Hi Carlos,
>
> > 1.- What do you think about making an IProgressAdapter for Ticket entity
> in
> > Tracker cube?
> >      (We find this handy to display progress bar for tickets.)
>
> sounds like a good idea.
>
> > 2.- Would it be so simple like adding these lines in
> > tracker/entities/ticket.py file?
> >
> > 2.1.- Create the IProgressAdapter
> >
> > from cubicweb.entities.adapters import IProgressAdapter
> > from cubicweb.selectors import is_instance
> >
> > class TicketIProgressAdapter(IProgressAdapter):
> >
> >     """IProgressAdapter for Tickets """
> >
> >     __select__ = is_instance('Ticket')
> >
> >     def progress_info(self):
> >
> >         """returns a dictionary describing load and progress of the
> > ticket"""
> >
> >         return {'notestimated': 0,
> >                 'estimated': 0,
> >                 'done': 0,
> >                 'todo': 0 }
> >
> > 2.2.- Add methods to Ticket Entity
> >
> > class Ticket(AnyEntity):
> >     __regid__ = 'Ticket'
> >
> > --------------------- add these 3 methods ---------------------
> >
> >     def done(self):
> >
> >         """returns work done in this ticket """
> >
> >         return self.load - self.load_left
> >
> >     def todo(self):
> >
> >         """returns remaining work in this ticket """
> >
> >         return self.load_left
> >
> >     def revised_cost(self):
> >
> >         """return total work estimated to this ticket """
> >
> >         return self.load
> >
> > Making the changes above, the progress bar view works for tickets too,
> but I
> > am not sure this is the best way to do it.
>
> I don't think that it display valuable information then. The methods you
> added
> on the  ticket entity should be properties of the adapter. Though the base
> adapter provides default implementation for them, based on information
> returned
> by progress info. And you've to implement the in_progress method which is
> also abstract on the base adapter. So something like:
>
> class TicketIProgressAdapter(IProgressAdapter):
>    """IProgressAdapter for Tickets """
>    __select__ = is_instance('Ticket')
>
>    def progress_info(self):
>        """returns a dictionary describing load and progress of the
> ticket"""
>        return {'notestimated': 0,
>                 'estimated': 1,
>                'done': self.entity.load,
>                'todo': self.entity.load - self.entity.load_left}
>
>    def in_progress(self):
>        """returns True if status is not finished"""
>        return self.entity.load_left != 0
>
> should be enough.
>
> --
> Sylvain Thénault                               LOGILAB, Paris (France)
> Formations Python, Debian, Méth. Agiles: http://www.logilab.fr/formations
> Développement logiciel sur mesure:       http://www.logilab.fr/services
> CubicWeb, the semantic web framework:    http://www.cubicweb.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubicweb.org/pipermail/cubicweb/attachments/20100910/03941388/attachment-0049.html>


More information about the Cubicweb mailing list