Example #1
0
    def post(self, *args, **kargs):
        currentUser = self.auth.get_user_by_session()

        timelog_key = time_log.Time_Log()

        timelog_key.project_key = self.session['current_project']

        timelog_key.task_key = ndb.Key(urlsafe=self.request.get('key'))

        timelog_key.assigne_key = self.user_model.get_by_id(
            currentUser['user_id']).key
        timelog_key.today_date = self.request.get('date')
        timelog_key.time = self.request.get('hours') + '.' + self.request.get(
            'minutes')

        if (self.request.get('billable')):
            timelog_key.billable = True

        timelog_key.description = self.request.get('description')

        if (self.request.get('task_completed')):
            timelog_key.task_completed = True

        timelog_key.set()
        self.response.write('true')
Example #2
0
    def post(self, *args, **kargs):
        currentUser = self.auth.get_user_by_session()

        timelog_key = time_log.Time_Log()

        timelog_key.project_key = self.session['current_project']

        timelog_key.task_key = ndb.Key(urlsafe=self.request.get('task_key'))

        # if self.request.get('sprint_key'):
        timelog_key.sprint_key = ndb.Key(
            urlsafe=self.request.get('sprint_key'))

        timelog_key.assigne_key = self.user_model.get_by_id(
            currentUser['user_id']).key

        if (self.request.get('date')):
            timelog_key.today_date = datetime.strptime(
                self.request.get('date'), '%d/%m/%Y').date()

        if (self.request.get('hours')):
            timelog_key.hour = int(self.request.get('hours'))
        else:
            timelog_key.hour = 00

        if (self.request.get('minutes')):
            timelog_key.minute = int(self.request.get('minutes'))
        else:
            timelog_key.minute = 00

        timelog_key.created_by = currentUser['email_address']
        timelog_key.status = True

        if (self.request.get('billable')):
            timelog_key.billable = True
        else:
            timelog_key.billable = False

        timelog_key.description = self.request.get('description')

        timelog_key.set()

        task_key = ndb.Key(urlsafe=self.request.get('task_key'))
        tasks = task_key.get()

        if (self.request.get('task_completed')):

            tasks.task_status = Status[2]
            tasks.modified_by = currentUser['email_address']
            tasks.modified_date = datetime.now()
            tasks.put()
        else:
            logging.info('not equal')
            tasks.task_status = Status[0]
            tasks.modified_by = currentUser['email_address']
            tasks.modified_date = datetime.now()
            tasks.put()

        self.response.write('true')
Example #3
0
    def get(self, *args, **kargs):
        taskKey = ndb.Key(urlsafe=self.request.get('key'))
        task = taskKey.get()
        projectKey = self.session['current_project']
        currentUser = self.auth.get_user_by_session()
        currentUser = self.user_model.get_by_id(currentUser['user_id']).key
        time_log_data = time_log.Time_Log()

        time_log_data = time_log_data.getByTask(taskKey)
        status = task.task_status
        self.render_template(
            "user_new/view_task.html", {
                "task": task,
                "time_log": time_log_data,
                "status": status,
                "user_obj": currentUser
            })
Example #4
0
    def post(self, *args, **kargs):
        key = ndb.Key(urlsafe=self.request.get('delete_key'))
        timelog_key = key.get()

        user_info = self.auth.get_user_by_session()
        timelog_key.modified_by = user_info['email_address']
        timelog_key.modified_date = datetime.now()
        timelog_key.status = False

        timelog_key.put()

        key = ndb.Key(urlsafe=self.request.get('task_key'))
        tasks = key.get()

        timelog = time_log.Time_Log()
        timelog_data = timelog.query().fetch()

        count = 0

        for i in timelog_data:
            if (i.status == True):
                if (i.task_key == key):
                    count = count + 1

        logging.info(count)

        if (count != 0):
            logging.info('time log exist')
            tasks.task_status = Status[2]
            tasks.modified_by = user_info['email_address']
            tasks.modified_date = datetime.now()
            tasks.put()
        else:
            logging.info('time log does not exist')
            tasks.task_status = Status[0]
            tasks.modified_by = user_info['email_address']
            tasks.modified_date = datetime.now()
            tasks.put()

        #user_key.delete()
        self.response.write("true")
    def get(self, *args, **kargs):
        week_number = 0
        day_number = 7
        projectKey = self.session['current_project']
        currentUser = self.auth.get_user_by_session()
        currentUser = self.user_model.get_by_id(currentUser['user_id']).key
        if self.request.get('from') and self.request.get('to'):
            logging.info('get')
            monday1 = datetime.strptime(self.request.get('from'),
                                        '%d/%m/%Y').date()
            monday2 = datetime.strptime(self.request.get('to'),
                                        '%d/%m/%Y').date()
            #monday1 = (start_date - timedelta(days=start_date.weekday()))
            #monday2 = (end_date - timedelta(days=end_date.weekday()))
            week_number = (monday2 - monday1).days / 7
            day_number = (monday2 - monday1).days % 7
            start = monday1
            prev_date = datetime.strftime(monday1 - timedelta(days=1),
                                          '%d/%m/%Y')
            next_date = datetime.strftime(monday2 + timedelta(days=8),
                                          '%d/%m/%Y')
        elif self.request.get('from') and not self.request.get('to'):
            dt = datetime.strptime(self.request.get('from'), '%d/%m/%Y').date()
            start = dt - timedelta(days=dt.weekday())
            week_number = 0
            day_number = 6
            prev_date = datetime.strftime(start - timedelta(days=1),
                                          '%d/%m/%Y')
            next_date = datetime.strftime(start + timedelta(days=8),
                                          '%d/%m/%Y')
        else:
            dt = date.today()
            start = dt - timedelta(days=dt.weekday())
            week_number = 0
            day_number = 6
            prev_date = datetime.strftime(start - timedelta(days=1),
                                          '%d/%m/%Y')
            next_date = datetime.strftime(start + timedelta(days=8),
                                          '%d/%m/%Y')

        #w=(monday2 - monday1).days/7
        week = []
        week_total = 0
        for j in range(0, week_number + 1):
            if j == week_number:
                d = day_number + 1
            else:
                d = 7
            for i in range(0, d):
                end = start + timedelta(days=i)

                if i == 6:
                    start = start + timedelta(days=7)
                    #range_to = end.strftime('%d/%m/%Y')
                week.append({
                    'week_number': j + 1,
                    'date': end,
                    'items': [],
                    'total': 0
                })

        logs = time_log.Time_Log().getByProjectUser(projectKey, currentUser)
        for w in week:
            for name in logs:
                key = name.today_date
                if key == w['date']:
                    w['items'].append(name)
                    w['total'] = w['total'] + name.total_effort
                    week_total = week_total + name.total_effort
        self.render_template(
            "user_new/timesheet.html", {
                "logs": week,
                'week_total': week_total,
                'previous': prev_date,
                'next': next_date
            })