Пример #1
0
    def handle(self, *args, **options):
        user_name = options['username']
        comm_name = options['commune']
        result = Im.crea_group_with_manager_and_user(user_name, comm_name)

        if result:
            print("Ok")
        else:
            raise CommandError("Creation failed")
Пример #2
0
    def handle(self, *args, **options):
        user_name = options['username']
        comm_name = options['commune']
        result = Im.crea_group_with_manager_and_user(user_name,comm_name)

        if result:
            print("Ok")
        else:
            raise CommandError("Creation failed")
Пример #3
0
def admin_view_addurb(request,
                      template='adminimio/imio_management_addurb.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormAddurb(request.POST)

        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            in_user = form.cleaned_data['in_user']
            in_password = form.cleaned_data['in_password']
            in_dbadresse = form.cleaned_data['in_dbadresse']
            in_dbport = form.cleaned_data['in_dbport']
            in_dbname = form.cleaned_data['in_dbname']
            in_dbuser = form.cleaned_data['in_dbuser']
            in_dbpassword = form.cleaned_data['in_dbpassword']
            in_workspace = form.cleaned_data['in_workspace']
            in_uri = form.cleaned_data['in_uri']
            in_groupname = form.cleaned_data['in_groupname']
            try:
                result, message = Im.addurb(in_user, in_password, in_dbadresse,
                                            in_dbport, in_dbname, in_dbuser,
                                            in_dbpassword, in_workspace,
                                            in_uri, in_groupname)
            except Exception as e:
                out['error'] = str(e.message)
        else:
            out['error'] = "Des paramètres sont manquant"

        if result == True:
            out['success'] = True
            message = 'Récuperation des couches terminée'
            messages.success(request, message)
            return render_to_response(template, RequestContext(request, out))
            status_code = 200
        else:
            status_code = 500
            message = out['error']
            messages.error(request, message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(json.dumps(out),
                            mimetype='application/json',
                            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))
Пример #4
0
def admin_view_addurb(request, template='adminimio/imio_management_addurb.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormAddurb(request.POST)

        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            in_user = form.cleaned_data['in_user']
            in_password = form.cleaned_data['in_password']
            in_dbadresse = form.cleaned_data['in_dbadresse']
            in_dbport = form.cleaned_data['in_dbport']
            in_dbname = form.cleaned_data['in_dbname']
            in_dbuser = form.cleaned_data['in_dbuser']
            in_dbpassword = form.cleaned_data['in_dbpassword']
            in_workspace = form.cleaned_data['in_workspace']
            in_uri = form.cleaned_data['in_uri']
            in_groupname = form.cleaned_data['in_groupname']
            try:
                result, message = Im.addurb(in_user, in_password, in_dbadresse, in_dbport, in_dbname, in_dbuser, in_dbpassword, in_workspace, in_uri, in_groupname)
            except Exception as e:
                out['error'] = str(e.message)
        else:
            out['error'] = "Des paramètres sont manquant"

        if result == True:
            out['success'] = True
            message = 'Récuperation des couches terminée'
            messages.success(request,message)
            return render_to_response(template, RequestContext(request, out))
            status_code = 200
        else:
            status_code = 500
            message = out['error']
            messages.error(request,message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(
            json.dumps(out),
            mimetype='application/json',
            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))
Пример #5
0
def admin_view_crea_group_with_manager(
        request, template='adminimio/imio_management_commune.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormCommuneUser(request.POST)

        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            user_name = form.cleaned_data['in_user']
            comm_name = form.cleaned_data['in_comm']

            try:
                result = Im.crea_group_with_manager_and_user(
                    user_name, comm_name)
            except Exception as e:
                out['error'] = str(e.message)

        else:
            out['error'] = "Des paramètres sont manquant"

        if result == True:
            out['success'] = True
            status_code = 200
            message = 'Groupes et utilisateurs crée'
            messages.success(request, message)
            return render_to_response(template, RequestContext(request, out))
        else:
            status_code = 500
            message = out['error']
            messages.error(request, message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(json.dumps(out),
                            mimetype='application/json',
                            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))
Пример #6
0
def admin_view_crea_group_with_manager(request, template='adminimio/imio_management_commune.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormCommuneUser(request.POST)

        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            user_name = form.cleaned_data['in_user']
            comm_name = form.cleaned_data['in_comm']
            
            try:
               result = Im.crea_group_with_manager_and_user(user_name,comm_name)
            except Exception as e:
                out['error'] = str(e.message)

        else:
            out['error'] = "Des paramètres sont manquant"

        if result == True:
            out['success'] = True
            status_code = 200
            message = 'Groupes et utilisateurs crée'
            messages.success(request,message)
            return render_to_response(template, RequestContext(request, out))
        else:
            status_code = 500
            message = out['error']
            messages.error(request,message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(
            json.dumps(out),
            mimetype='application/json',
            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))
Пример #7
0
def admin_view_updatelayer(
        request, template='adminimio/imio_management_updatelayer.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormUpdateLayer(request.POST)
        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            try:
                created, updated, failed = Im.updatelayer()
                result = True
                out['success'] = True
            except Exception as e:
                out['error'] = str(e.message)
        else:
            out['error'] = "Des paramètres sont manquant"
        if result == True:
            out['success'] = True
            status_code = 200
            message = 'Mise à jour réussie'
            messages.success(request, message)
            return render_to_response(template, RequestContext(request, out))
        else:
            status_code = 500
            message = out['error']
            messages.error(request, message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(json.dumps(out),
                            mimetype='application/json',
                            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))
Пример #8
0
def admin_view_updatelayer(request, template='adminimio/imio_management_updatelayer.html'):
    result = False
    out = {}
    if request.method == 'POST':
        out['success'] = False
        #token_session = request.token
        form = ValidFormUpdateLayer(request.POST)
        if form.is_valid():
            form_token = form.cleaned_data['csrf_token']
            try:
                created, updated, failed = Im.updatelayer()
                result = True
                out['success'] = True
            except Exception as e:
                out['error'] = str(e.message)
        else:
            out['error'] = "Des paramètres sont manquant"
        if result == True:
            out['success'] = True
            status_code = 200
            message = 'Mise à jour réussie'
            messages.success(request, message)
            return render_to_response(template, RequestContext(request, out))
        else:
            status_code = 500
            message = out['error']
            messages.error(request, message)
            return render_to_response(template, RequestContext(request, out))

        return HttpResponse(
            json.dumps(out),
            mimetype='application/json',
            status=status_code)
    else:
        out.update(csrf(request))
        return render_to_response(template, RequestContext(request, out))