Commit d0b54b7f authored by Thomas Frion's avatar Thomas Frion
Browse files

[FEAT] Search an operation by name, code, asmid

parent 43f5ad00
import { Component, OnInit, Input, OnDestroy } from '@angular/core'; import { Component, OnInit, Input, OnDestroy } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; import { FormBuilder, FormGroup } from '@angular/forms';
import { ChoucasApi } from 'src/app/pghm-api/choucas/choucas.api.service'; import { ChoucasApi } from 'src/app/pghm-api/choucas/choucas.api.service';
import { OperationResource } from 'src/app/pghm-api/choucas/resources/operation.resource'; import { OperationResource } from 'src/app/pghm-api/choucas/resources/operation.resource';
import { MapService } from 'src/app/map/services/map.service'; import { MapService } from 'src/app/map/services/map.service';
import { ActiveOperationWSService } from 'src/app/pghm-api/choucas/websockets/operationws.service'; import { ActiveOperationWSService } from 'src/app/pghm-api/choucas/websockets/operationws.service';
import { PermsManagerService } from 'src/app/pghm-api/perms-manager.service'; import { PermsManagerService } from 'src/app/pghm-api/perms-manager.service';
import { Perms } from 'src/app/pghm-api/perm-list'; import { Perms } from 'src/app/pghm-api/perm-list';
@Component({ @Component({
selector: 'app-operation-form-init', selector: 'app-operation-form-init',
......
...@@ -8,7 +8,6 @@ import { ChoucasApi } from 'src/app/pghm-api/ch ...@@ -8,7 +8,6 @@ import { ChoucasApi } from 'src/app/pghm-api/ch
import { environment } from 'src/environments/environment'; import { environment } from 'src/environments/environment';
import { OperationResource, OperationGeoInfoResource } from 'src/app/pghm-api/choucas/resources/operation.resource'; import { OperationResource, OperationGeoInfoResource } from 'src/app/pghm-api/choucas/resources/operation.resource';
import { OperationInitParams } from './models/operation-inti-params'; import { OperationInitParams } from './models/operation-inti-params';
import { Router } from '@angular/router';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
......
...@@ -53,7 +53,11 @@ class OperationList(APIView): ...@@ -53,7 +53,11 @@ class OperationList(APIView):
class OperationDetail(APIView): class OperationDetail(APIView):
def get_obj(self, code): def get_obj(self, code):
try: try:
return OperationModel.objects.get(code=code) if code.isnumeric():
return OperationModel.objects.get(Q(code=code) | Q(name=code) | Q(asmid=code))
else:
return OperationModel.objects.get(Q(code=code) | Q(name=code))
except OperationModel.DoesNotExist: except OperationModel.DoesNotExist:
raise Http404 raise Http404
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment