def task(request): Staff = user_obj.getStaffUserId(request.user.id) if not Staff: return False if request.COOKIES.has_key('date'): date = date_sql(request.COOKIES['date']) else: date = date_sql('') duty_main = user_obj.getDutiesStaff(date, Staff.id) if request.COOKIES.has_key('duty'): duty_id = int(request.COOKIES['duty']) else: duty_id = None duty = user_obj.getDutiesStaff(date, Staff.id, duty_id) ret = True if not duty: ret = False if duty_main and duty_id and duty_main.duty.id != duty_id: ret = user_obj.isChildrenNodeId(duty_main.duty.id, duty_id) return ret
def task(request): if request.GET.has_key('action') and request.GET['action'] == 'add_edit_task': return add_edit_task(request) if request.GET.has_key('action') and request.GET['action'] == 'get_status_all': return get_status_all(request) if request.GET.has_key('action') and request.GET['action'] == 'is_valid_task_edit': return is_valid_task_edit(request) if request.GET.has_key('action') and request.GET['action'] == 'add_edit_date': date_start = date_sql(request.GET['date_start']) date_end = date_sql(request.GET['date_end']) error = {} if date_start > date_end: error = { 'error': u'Неверное заданны даты!' } return add_edit_task(request, error) if request.COOKIES.has_key('duty'): duty_id = int(request.COOKIES['duty']) else: duty_id = None if request.COOKIES.has_key('date'): date = date_sql(request.COOKIES['date']) else: date = date_sql('') duty = user_obj.getStaffDuties(date, duty_id) if not duty: return render(request, 'site/not.html', {'text': u'Это должность пустая, вы не можете на нее проставить задачи!'}) tasks = statics.task_obj.getTasksDuty(duty.duty_id) param = { 'duty': duty, 'staff': user_obj.getStaffUserId(request.user.id), 'curent_site': Site.objects.get_current(), 'tasks': tasks, 'date': date, } return render(request, 'task/task.html', param)
def add_edit_task(request, ret={}): param = request.GET.copy() if request.COOKIES.has_key('duty'): duty_id = int(request.COOKIES['duty']) else: duty_id = None if request.COOKIES.has_key('date'): date = date_sql(request.COOKIES['date']) else: date = date_sql('') duty = user_obj.getStaffDuties(date, duty_id) if int(param['id']) == 0: param['date_start'] = date.strftime('%d.%m.%Y') param['date_end'] = date.strftime('%d.%m.%Y') param['responsible'] = duty.duty param['staff_id'] = user_obj.getStaffUserId(request.user.id).id param['status_id'] = 1 param['percent'] = 0 elif param.has_key('status_id'): ret = is_valid_task_edit(request, { 'task_id': int(param['id']), 'valid': 'status_not', 'status_id': param['status_id'], }) if ret.has_key('error') and ret['error'] != u'': return HttpResponse(json.dumps(ret)) task = statics.task_obj.addEditTask(param) if task: ret['name'] = task.name return HttpResponse(json.dumps(ret)) return HttpResponse(json.dumps({ 'error': u'Нету такой задачи!' }))