def post(self, request): user, profile = user_and_profile(request) instance = get_object_or_404(Organisation, id=request.GET.get('id')) is_admin = profile.is_admin is_referent = LiaisonsReferents.objects.filter( profile=profile, organisation=instance, validated_on__isnull=False) and True or False if is_referent or is_admin: json = { 'abstract': request.POST.get('abstract', None), 'srs': [crs.authority for crs in SupportedCrs.objects.all()], 'title': request.POST.get('title', None) } try: MRAHandler.update_ows_settings('ows', json, ws_name=instance.slug) except Exception as e: messages.error(request, e.__str__()) else: messages.success(request, "Le service OGC est mis à jour.") return JsonResponse(data={}) raise Http404()
def post(self, request): id = request.GET.get('id') if not id: raise Http404() organisation = get_object_or_404(Organisation, id=id) user = request.user profile = user.profile is_admin = profile.is_admin is_referent = LiaisonsReferents.objects.filter( profile=profile, organisation__id=id, validated_on__isnull=False) and True or False if not (is_referent or is_admin): raise Http404() json = { 'abstract': request.POST.get('abstract', None), 'srs': [crs.authority for crs in SupportedCrs.objects.all()], 'title': request.POST.get('title', None), } try: MRAHandler.update_ows_settings('ows', json, ws_name=organisation.slug) except Exception as e: messages.error(request, e.__str__()) else: messages.success(request, "Le service OGC a été mis à jour avec succès.") return redirect('idgo_admin:show_organisation', id=id)