Exemplo n.º 1
0
    def addTrack(self,year,month,day,responsibleParty,hours,title):
        core = self.getCommandSet('core')
        context = self.context.aq_inner
         
        error_hour, error_date = '',''
        try:
            deadline = DateTime(year, month, day)
            core.replaceInnerHTML(core.getSelector('parentnodecss', '.trackitem|.errmsgDate'), '')
            core.removeClass(core.getSelector('parentnodecss', '.trackitem|.errmsgDate'), 'error')
        except:
            error_date = translate(_(u'va_date_error', default='Date is invalid, please currect.'), context=self.request)


        if hours == '':
            error_date = translate(_(u'va_need_hour', default='Need hour!'), context=self.request)
        else:
            try:
                parseHour(hours)
                core.replaceInnerHTML(core.getSelector('parentnodecss', '.trackitem|.errmsgHour'), '')
                core.removeClass(core.getSelector('parentnodecss', '.trackitem|.errmsgHour'), 'error')
            except:
                error_date = translate(_(u'va_hour_error', default='Hour is invalid, please currect.'), context=self.request)

        if error_date:
            error_date = error_date.decode('utf', 'replace')
            core.replaceInnerHTML(core.getSelector('parentnodecss', '.trackitem|.errmsgDate'), error_date)
            core.addClass(core.getSelector('parentnodecss', '.trackitem|.errmsgDate'), 'error')
            core.toggleClass(core.getSelector('parentnodecss','.trackitem|.submit'),'hideme')
            return self.render()

        if error_hour:
            error_hour = error_hour.decode('utf', 'replace')
            core.replaceInnerHTML(core.getSelector('parentnodecss', '.trackitem|.errmsgHour'), error_hour)
            core.addClass(core.getSelector('parentnodecss', '.trackitem|.errmsgHour'), 'error')
            core.toggleClass(core.getSelector('parentnodecss','.trackitem|.submit'),'hideme')
            return self.render()


        o = self._addTrack(year,month,day,responsibleParty,hours,title)

        timelogs = context.getRawRelatedItems()
        timelogs.append(o.UID())
        context.setRelatedItems(timelogs)

        wftool = getToolByName(self.context, 'portal_workflow')
        state = wftool.getInfoFor(self.context, 'review_state')
        macro = macros_todo.macros[state]

        content = self.header_macros(the_macro=macro,
                item = context)
        content = force_unicode(content, 'utf')

        ksscore = self.getCommandSet('core')
        ksscore.replaceHTML('#item_' + context.getId(), content)

        return self.render()
Exemplo n.º 2
0
    def save_time_log(self, year, month, day, responsibleParty, hours, title, sum_hours):

        obj = self.context
        old_hours = obj.getHours()
        
        ksscore = self.getCommandSet("core")

        error = ''
        try:
            deadline = DateTime(year[1], month[1], day[1])
        except:
            error = translate(_(u'va_time_error', default='The date ${time} is invalib, please correct.', mapping={u'time':str(year[1])+'/'+str(month[1])+'/'+str(day[1])}), context=self.request)
        if hours[1] == '':
            error += translate(_(u'va_time_need', default="Need Time;"), context=self.request)
        else:
            try:
                parseHour(hours[1])
            except:
                error += translate(_(u'va_time_invalib', default='Time is invalib, please correct;'), context=self.request)
        if title[1] == '':
            error += translate(_(u'va_description_need', default='Need description;'), context=self.request)
        if error:
            error = error.decode('utf', 'replace')
            ksscore.toggleClass(ksscore.getSelector('parentnodecss','.kssDeletionRegion|.submit'),'hideme')
            self.getCommandSet('plone').issuePortalMessage(error,translate(_(u'error'), context=self.request))
            return self.render()


        obj.setTitle(title[1])
        obj.setDate(deadline)
        obj.setResponsibleParty(responsibleParty[1])
        obj.setHours(parseHour(hours[1]))
        obj.reindexObject()

        the_macro = self.timetracker_template.macros["item"]
        content = self.header_macros(the_macro=the_macro,
                item=obj,
                )

        #if self.request.get('HTTP_USER_AGENT', '').find('MSIE') != -1:
        #    content = content.strip().replace('<', '&lt;').replace('>', '&gt;')

        ksscore = self.getCommandSet("core")
        selector = ksscore.getParentNodeSelector(".kssDeletionRegion")
        ksscore.insertHTMLBefore(selector, content)
        ksscore.deleteNodeAfter(selector)
        ksscore.deleteNode(selector)

        sum_hours = float(sum_hours) - old_hours + obj.getHours()
        ksscore.setAttribute('#sum_hours', name="value", value=str(sum_hours))
        return self.render()
Exemplo n.º 3
0
    def add_time_log(self, year, month, day, responsibleParty, hours, title, sum_hours):
        ksscore = self.getCommandSet("core")

        error = ''
        try:
            deadline = DateTime(year, month, day)
        except:
            error = translate(_(u'va_time_error', default='The date ${time} is invalib, please correct.', mapping={u'time':str(year)+'/'+str(month)+'/'+str(day)}), context=self.request)
        if hours == '':
            error += translate(_(u'va_time_need', default="Need Time;"), context=self.request)
        else:
            try:
                parseHour(hours)
            except:
                error += translate(_(u'va_time_invalib', default='Time is invalib, please correct;'), context=self.request)
        if title == '':
            error += translate(_(u'va_description_need', default='Need description;'), context=self.request)
        if error:
            error = error.decode('utf', 'replace')
#            core = self.getCommandSet('core')
#            core.replaceInnerHTML(core.getSelector('parentnodecss', '.documentContent|.errmsg'), error)
#            core.addClass(core.getSelector('parentnodecss', '.documentContent|.errmsg'), 'error')
            ksscore.toggleClass(ksscore.getSelector('parentnodecss','.AddTimeTrack|.submit'),'hideme')
            self.getCommandSet('plone').issuePortalMessage(error,translate(_(u'error'), context=self.request))
            return self.render()

 
        obj = self._createTimelog(year, month, day, responsibleParty, hours, title, sum_hours)

        the_macro = self.timetracker_template.macros["item"]

        content = self.header_macros(the_macro=the_macro,
                item=obj,
                )

        selector = ksscore.getParentNodeSelector("#AddTimeTrack")

        #if self.request.get('HTTP_USER_AGENT', '').find('MSIE') != -1:
        #    content = content.strip().replace('<', '&lt;').replace('>', '&gt;')
        ksscore.insertHTMLAfter("#AddTimeTrack", content)

        ksszopen=self.getCommandSet('zopen')
        ksszopen.clear(ksscore.getSelector('parentnodecss', \
                '.AddTimeTrack|.hours input'))
        ksszopen.clear(ksscore.getSelector('parentnodecss', \
                '.AddTimeTrack|.desc input'))

        sum_hours = float(sum_hours) + obj.getHours()
        ksscore.setAttribute('#sum_hours', name="value", value=str(sum_hours))
        ksscore.toggleClass(ksscore.getSelector('parentnodecss','.AddTimeTrack|.submit'),'hideme')
        return self.render()
Exemplo n.º 4
0
    def _addTrack(self,year,month,day,responsibleParty,hours,title):
        core = self.getCommandSet('core')
        
        context = self.context.aq_inner
        tracker = context.getProject().time
        random_id = str(random.randrange(100000, 999999))

        ids = tracker.objectIds()
        while random_id in ids:
            random_id = str(random.randrange(100000, 999999))

        deadline = DateTime(year, month, day)

        tracker.invokeFactory('TimeLog', random_id)
        o = getattr(tracker, random_id)

        o.setTitle(title)
        o.setDate(deadline)
        o.setResponsibleParty(responsibleParty)

        o.setHours(parseHour(hours))
        o.setRelatedItems([context])
        o.setDescription(context.Title().decode('utf-8')[:30])
        o.reindexObject()

        return o
Exemplo n.º 5
0
    def _addTrack(self, year, month, day, responsibleParty, hours, title):
        core = self.getCommandSet('core')

        context = self.context.aq_inner
        tracker = context.getProject().time
        random_id = str(random.randrange(100000, 999999))

        ids = tracker.objectIds()
        while random_id in ids:
            random_id = str(random.randrange(100000, 999999))

        deadline = DateTime(year, month, day)

        tracker.invokeFactory('TimeLog', random_id)
        o = getattr(tracker, random_id)

        o.setTitle(title)
        o.setDate(deadline)
        o.setResponsibleParty(responsibleParty)

        o.setHours(parseHour(hours))
        o.setRelatedItems([context])
        o.setDescription(context.Title().decode('utf-8')[:30])
        o.reindexObject()

        return o
Exemplo n.º 6
0
    def _createTimelog(self, year, month, day, responsibleParty, hours, title, sum_hours):
        if not title:
            return

        deadline = DateTime(year, month, day)

        random_id = str(random.randrange(100000, 999999))
        while random_id in self.context:
            random_id = str(random.randrange(100000, 999999))

        self.context.invokeFactory('TimeLog', random_id)
        o = getattr(self.context, random_id)

        o.setTitle(title)
        o.setDate(deadline)
        o.setResponsibleParty(responsibleParty)
        o.setHours(parseHour(hours))
        o.reindexObject()

        return o
Exemplo n.º 7
0
    def _createTimelog(self, year, month, day, responsibleParty, hours, title,
                       sum_hours):
        if not title:
            return

        deadline = DateTime(year, month, day)

        random_id = str(random.randrange(100000, 999999))
        while random_id in self.context:
            random_id = str(random.randrange(100000, 999999))

        self.context.invokeFactory('TimeLog', random_id)
        o = getattr(self.context, random_id)

        o.setTitle(title)
        o.setDate(deadline)
        o.setResponsibleParty(responsibleParty)
        o.setHours(parseHour(hours))
        o.reindexObject()

        return o
Exemplo n.º 8
0
    def addTrackMore(self, year, month, day, responsibleParty, hours, title):
        core = self.getCommandSet('core')
        context = self.context.aq_inner

        error_hour, error_date = '', ''
        try:
            deadline = DateTime(year, month, day)
            core.replaceInnerHTML(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgDate'), '')
            core.removeClass(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgDate'), 'error')
        except:
            error_date = translate(_(
                u'va_date_error', default='Date is invalid, please currect.'),
                                   context=self.request)

        if hours == '':
            error_date = translate(_(u'va_need_hour', default='Need hour!'),
                                   context=self.request)
        else:
            try:
                parseHour(hours)
                core.replaceInnerHTML(
                    core.getSelector('parentnodecss',
                                     '.trackitemmore|.errmsgHour'), '')
                core.removeClass(
                    core.getSelector('parentnodecss',
                                     '.trackitemmore|.errmsgHour'), 'error')
            except:
                error_date = translate(_(
                    u'va_hour_error',
                    default='Hour is invalid, please currect.'),
                                       context=self.request)

        if error_date:
            error_date = error_date.decode('utf', 'replace')
            core.replaceInnerHTML(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgDate'), error_date)
            core.addClass(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgDate'), 'error')
            core.toggleClass(
                core.getSelector('parentnodecss', '.trackitem|.submit'),
                'hideme')
            return self.render()

        if error_hour:
            error_hour = error_hour.decode('utf', 'replace')
            core.replaceInnerHTML(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgHour'), error_hour)
            core.addClass(
                core.getSelector('parentnodecss',
                                 '.trackitemmore|.errmsgHour'), 'error')
            core.toggleClass(
                core.getSelector('parentnodecss', '.trackitem|.submit'),
                'hideme')
            return self.render()

        o = self._addTrack(year, month, day, responsibleParty, hours, title)

        timelogs = context.getRawRelatedItems()
        timelogs.append(o.UID())
        context.setRelatedItems(timelogs)

        macro = macros_todo_more.macros['todo_more']

        content = self.header_macros(the_macro=macro, item=context)
        content = force_unicode(content, 'utf')

        ksscore = self.getCommandSet('core')
        ksscore.replaceHTML('#todo_more', content)

        return self.render()
Exemplo n.º 9
0
    def save_time_log(self, year, month, day, responsibleParty, hours, title,
                      sum_hours):

        obj = self.context
        old_hours = obj.getHours()

        ksscore = self.getCommandSet("core")

        error = ''
        try:
            deadline = DateTime(year[1], month[1], day[1])
        except:
            error = translate(
                _(u'va_time_error',
                  default='The date ${time} is invalib, please correct.',
                  mapping={
                      u'time':
                      str(year[1]) + '/' + str(month[1]) + '/' + str(day[1])
                  }),
                context=self.request)
        if hours[1] == '':
            error += translate(_(u'va_time_need', default="Need Time;"),
                               context=self.request)
        else:
            try:
                parseHour(hours[1])
            except:
                error += translate(_(
                    u'va_time_invalib',
                    default='Time is invalib, please correct;'),
                                   context=self.request)
        if title[1] == '':
            error += translate(_(u'va_description_need',
                                 default='Need description;'),
                               context=self.request)
        if error:
            error = error.decode('utf', 'replace')
            ksscore.toggleClass(
                ksscore.getSelector('parentnodecss',
                                    '.kssDeletionRegion|.submit'), 'hideme')
            self.getCommandSet('plone').issuePortalMessage(
                error, translate(_(u'error'), context=self.request))
            return self.render()

        obj.setTitle(title[1])
        obj.setDate(deadline)
        obj.setResponsibleParty(responsibleParty[1])
        obj.setHours(parseHour(hours[1]))
        obj.reindexObject()

        the_macro = self.timetracker_template.macros["item"]
        content = self.header_macros(
            the_macro=the_macro,
            item=obj,
        )

        #if self.request.get('HTTP_USER_AGENT', '').find('MSIE') != -1:
        #    content = content.strip().replace('<', '&lt;').replace('>', '&gt;')

        ksscore = self.getCommandSet("core")
        selector = ksscore.getParentNodeSelector(".kssDeletionRegion")
        ksscore.insertHTMLBefore(selector, content)
        ksscore.deleteNodeAfter(selector)
        ksscore.deleteNode(selector)

        sum_hours = float(sum_hours) - old_hours + obj.getHours()
        ksscore.setAttribute('#sum_hours', name="value", value=str(sum_hours))
        return self.render()
Exemplo n.º 10
0
    def add_time_log(self, year, month, day, responsibleParty, hours, title,
                     sum_hours):
        ksscore = self.getCommandSet("core")

        error = ''
        try:
            deadline = DateTime(year, month, day)
        except:
            error = translate(_(
                u'va_time_error',
                default='The date ${time} is invalib, please correct.',
                mapping={
                    u'time': str(year) + '/' + str(month) + '/' + str(day)
                }),
                              context=self.request)
        if hours == '':
            error += translate(_(u'va_time_need', default="Need Time;"),
                               context=self.request)
        else:
            try:
                parseHour(hours)
            except:
                error += translate(_(
                    u'va_time_invalib',
                    default='Time is invalib, please correct;'),
                                   context=self.request)
        if title == '':
            error += translate(_(u'va_description_need',
                                 default='Need description;'),
                               context=self.request)
        if error:
            error = error.decode('utf', 'replace')
            #            core = self.getCommandSet('core')
            #            core.replaceInnerHTML(core.getSelector('parentnodecss', '.documentContent|.errmsg'), error)
            #            core.addClass(core.getSelector('parentnodecss', '.documentContent|.errmsg'), 'error')
            ksscore.toggleClass(
                ksscore.getSelector('parentnodecss', '.AddTimeTrack|.submit'),
                'hideme')
            self.getCommandSet('plone').issuePortalMessage(
                error, translate(_(u'error'), context=self.request))
            return self.render()

        obj = self._createTimelog(year, month, day, responsibleParty, hours,
                                  title, sum_hours)

        the_macro = self.timetracker_template.macros["item"]

        content = self.header_macros(
            the_macro=the_macro,
            item=obj,
        )

        selector = ksscore.getParentNodeSelector("#AddTimeTrack")

        #if self.request.get('HTTP_USER_AGENT', '').find('MSIE') != -1:
        #    content = content.strip().replace('<', '&lt;').replace('>', '&gt;')
        ksscore.insertHTMLAfter("#AddTimeTrack", content)

        ksszopen = self.getCommandSet('zopen')
        ksszopen.clear(ksscore.getSelector('parentnodecss', \
                '.AddTimeTrack|.hours input'))
        ksszopen.clear(ksscore.getSelector('parentnodecss', \
                '.AddTimeTrack|.desc input'))

        sum_hours = float(sum_hours) + obj.getHours()
        ksscore.setAttribute('#sum_hours', name="value", value=str(sum_hours))
        ksscore.toggleClass(
            ksscore.getSelector('parentnodecss', '.AddTimeTrack|.submit'),
            'hideme')
        return self.render()