Exemple #1
0
    def show_permit(request, pk):
        id = pk
        if request.method == 'POST':
            form = PermitForm(request.POST)
            permit = PermitGateway.find_by_id(_id=pk)
            if form.is_valid():
                permit.update_info(form)
                permit.save()
                perm = Permit.objects.get(id=id)

                permit_form = PermitForm(instance=perm)

                context = {
                    'permit': permit,
                    'form': permit_form,
                    'error': 0,
                    'method': 'post',
                    'id': id
                }
            else:
                context = {'error': 1}
            return context
        else:
            permit = PermitGateway.find_by_id(_id=pk)
            permit_form = PermitForm(instance=Permit.objects.get(id=id))
            context = {
                'reqobject': permit,
                'form': permit_form,
                'error': 0,
                'method': 'get',
                'id': id
            }
            return context
Exemple #2
0
 def print(request, pk):
     permit = PermitGateway.find_by_id(_id=pk)
     permit.status = u'PRI'
     permit.save()
     context = {
         'permit': permit,
     }
     return context
Exemple #3
0
 def print(request, pk):
     permit = PermitGateway.find_by_id(_id=pk)
     permit.status = u'PRI'
     permit.save()
     context = {
         'permit': permit,
     }
     return context
Exemple #4
0
 def print_permit(pk):
     permit = PermitGateway.find_by_id(_id=pk)
     pos = PositionGateway.find_by_id(_id=permit.position_id)
     dep = DepartGateway.find_by_id(_id=permit.department_id)
     if pos != None:
         permit.position = pos.name
     if dep != None:
         permit.department = dep.full_name()
     permit.id = pk
     context = {
         'permit': permit,
     }
     return context
Exemple #5
0
 def print_permit(pk):
     permit = PermitGateway.find_by_id(_id=pk)
     pos = PositionGateway.find_by_id(_id=permit.position_id)
     dep = DepartGateway.find_by_id(_id=permit.department_id)
     if pos != None:
         permit.position = pos.name
     if dep != None:
         permit.department = dep.full_name()
     permit.id = pk
     context = {
         'permit': permit,
     }
     return context
Exemple #6
0
    def permits(request):
        permits = PermitGateway.all()
        for permit in permits:
            pos = PositionGateway.find_by_id(_id=permit.position_id)
            dep = DepartGateway.find_by_id(_id=permit.department_id)
            if pos != None:
                permit.position = pos.name
            if dep != None:
                permit.department = dep.full_name()

        context = {
            'permits': permits,
        }
        return context
Exemple #7
0
    def permits(request):
        permits = PermitGateway.all()
        for permit in permits:
            pos = PositionGateway.find_by_id(_id=permit.position_id)
            dep = DepartGateway.find_by_id(_id=permit.department_id)
            if pos != None:
                permit.position = pos.name
            if dep != None:
                permit.department = dep.full_name()

        context = {
            'permits': permits,
        }
        return context
Exemple #8
0
    def show_permit(request, pk):
        id = pk
        if request.method == 'POST':
            form = PermitForm(request.POST)
            permit = PermitGateway.find_by_id(_id=pk)
            if form.is_valid():
                permit.update_info(form)
                permit.save()
                perm = Permit.objects.get(id=id)

                permit_form = PermitForm(instance=perm)

                context = {
                    'permit': permit,
                    'form': permit_form,
                    'error': 0,
                    'method': 'post',
                    'id': id
                }
            else:
                context = {
                    'error': 1
                }
            return context
        else:
            permit = PermitGateway.find_by_id(_id=pk)
            permit_form = PermitForm(instance=Permit.objects.get(id=id))
            context = {
                'reqobject': permit,
                'form': permit_form,
                'error': 0,
                'method': 'get',
                'id': id

            }
            return context
Exemple #9
0
    def deletion(pk):
        requests = RequestGateway.find_by_fields(department_id=pk)
        permits = PermitGateway.find_by_fields(department_id=pk)
        persons = PersonGateway.find_by_fields(department_id=pk)
        for per in permits:
            per.department_id = None

        for req in requests:
            req.department_id = None

        for per in persons:
            per.department_id = None

        MyRequestt.find_by_id(_id=pk)\
            .delete()
        return 1
Exemple #10
0
    def deletion(pk):
        requests = RequestGateway.find_by_fields(department_id=pk)
        permits = PermitGateway.find_by_fields(department_id=pk)
        persons = PersonGateway.find_by_fields(department_id=pk)
        for per in permits:
            per.department_id = None

        for req in requests:
            req.department_id = None

        for per in persons:
            per.department_id = None

        MyRequestt.find_by_id(_id=pk)\
            .delete()
        return 1
Exemple #11
0
    def delete(pk):
        position_id = pk
        position = PositionGateway.find_by_id(_id=position_id)

        position.delete()
        requests = RequestGateway.find_by_fields(position_id=position_id)
        permits = PermitGateway.find_by_fields(position_id=position_id)
        persons = PersonGateway.find_by_fields(position_id=position_id)
        for per in permits:
            per.department_id = None

        for req in requests:
            req.department_id = None

        for per in persons:
            per.department_id = None
        return 1
Exemple #12
0
    def permits_of_person(pk):
        person = PersonGateway.find_by_id(_id=pk)
        person.department = DepartGateway.find_by_id(
            _id=person.department_id).full_name()
        person.position = PositionGateway.find_by_id(
            _id=person.position_id).name
        permits = PermitGateway.find_by_fields(person=person)
        for permit in permits:
            pos = PositionGateway.find_by_id(_id=permit.position_id)
            dep = DepartGateway.find_by_id(_id=permit.department_id)
            if pos != None:
                permit.position = pos.name
            if dep != None:
                permit.department = dep.full_name()

        context = {'permits': permits, 'person': person}
        return context
Exemple #13
0
    def delete(pk):
        position_id = pk
        position = PositionGateway.find_by_id(_id = position_id)

        position.delete()
        requests = RequestGateway.find_by_fields(position_id=position_id)
        permits = PermitGateway.find_by_fields(position_id=position_id)
        persons = PersonGateway.find_by_fields(position_id=position_id)
        for per in permits:
            per.department_id = None

        for req in requests:
            req.department_id = None

        for per in persons:
            per.department_id = None
        return 1
Exemple #14
0
    def permits_of_person(pk):
        person = PersonGateway.find_by_id(_id = pk)
        person.department = DepartGateway.find_by_id(_id= person.department_id).full_name()
        person.position = PositionGateway.find_by_id(_id = person.position_id).name
        permits = PermitGateway.find_by_fields(person = person)
        for permit in permits:
            pos = PositionGateway.find_by_id(_id=permit.position_id)
            dep = DepartGateway.find_by_id(_id=permit.department_id)
            if pos != None:
                permit.position = pos.name
            if dep != None:
                permit.department = dep.full_name()

        context = {
            'permits': permits,
            'person': person
        }
        return context