Beispiel #1
0
def project_update(request, agent_slug, project_slug):
    if request.user.is_superuser:
        project = get_object_or_404(core_models.Project,
                                    agent__slug=agent_slug,
                                    slug=project_slug)
    else:
        project = get_object_or_404(core_models.Project,
                                    agent__slug=agent_slug,
                                    slug=project_slug,
                                    user=request.user)

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(
            request.POST, frontpage_forms.ProjectForm, instance=project)
        if form.is_valid():
            queue = frontpage_queues.ProjectDatasetQueue.get(request)
            frontpage_helpers.save_project_form(request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(
                    request, ugettext("Projektas „%s“ atnaujintas." % project))
                return redirect(project)
    else:
        form = frontpage_forms.ProjectForm(instance=project)

    return render(
        request, 'frontpage/project_form.html', {
            'form':
            formrenderer.render(request,
                                form,
                                title=project.title,
                                submit=ugettext('Pateikti')),
        })
Beispiel #2
0
def project_form(request):
    form_title = ugettext('Pateikti naują projektą')

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(
            request.POST, frontpage_forms.ProjectForm)
        if form.is_valid():
            queue = frontpage_queues.ProjectDatasetQueue.get(request)
            project = frontpage_helpers.save_project_form(
                request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(
                    request,
                    ugettext("Projektas „%s“ sėkmingai sukurtas." % project))
                return redirect(project)
    else:
        form = frontpage_forms.ProjectForm()

    return render(
        request, 'frontpage/project_form.html', {
            'form':
            formrenderer.render(
                request, form, title=form_title, submit=ugettext('Pateikti')),
        })
Beispiel #3
0
def dataset_update(request, agent_slug, dataset_slug):
    if request.user.is_superuser:
        dataset = get_object_or_404(core_models.Dataset,
                                    agent__slug=agent_slug,
                                    slug=dataset_slug)
    else:
        dataset = get_object_or_404(core_models.Dataset,
                                    agent__slug=agent_slug,
                                    slug=dataset_slug,
                                    user=request.user)

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(
            request.POST, frontpage_forms.DatasetForm, instance=dataset)
        if form.is_valid():
            queue = frontpage_queues.DatasetSourceQueue.get(request)
            frontpage_helpers.save_dataset_form(request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(
                    request,
                    ugettext("Duomenų šaltinis „%s“ atnaujintas." % dataset))
                return redirect(dataset)
    else:
        form = frontpage_forms.DatasetForm(instance=dataset)

    return render(
        request, 'frontpage/dataset_form.html', {
            'form':
            formrenderer.render(request,
                                form,
                                title=dataset.title,
                                submit=ugettext("Pateikti")),
        })
Beispiel #4
0
    def form(self, form):
        title = ugettext('Pateikti naują duomenų šaltinį')
        submit = ugettext('Pateikti')
        description = ''

        if self.item:
            title = ugettext('Informacija apie duomenų šaltinį')
            description = self.item.message
        return formrenderer.render(self.request, form, title=title, submit=submit, description=description)
def settings(request):
    if request.method == 'POST':
        form = accounts_forms.SettingsForm(request.POST, instance=request.user)
        if form.is_valid():
            form.save()
            messages.success(request, ugettext("Nustatymai buvo sėkimingai išsaugoti."))
            return redirect('accounts_settings')
    else:
        form = accounts_forms.SettingsForm(instance=request.user)
    return render(request, 'accounts/settings.html', {
        'form': formrenderer.render(request, form, title=ugettext("Profilio nustatymai"), submit=ugettext("Saugoti")),
    })
Beispiel #6
0
    def form(self, form):
        title = ugettext('Pateikti naują duomenų šaltinį')
        submit = ugettext('Pateikti')
        description = ''

        if self.item:
            title = ugettext('Informacija apie duomenų šaltinį')
            description = self.item.message
        return formrenderer.render(self.request,
                                   form,
                                   title=title,
                                   submit=submit,
                                   description=description)
Beispiel #7
0
def settings(request):
    if request.method == 'POST':
        form = accounts_forms.SettingsForm(request.POST, instance=request.user)
        if form.is_valid():
            form.save()
            messages.success(request,
                             ugettext("Nustatymai buvo sėkimingai išsaugoti."))
            return redirect('accounts_settings')
    else:
        form = accounts_forms.SettingsForm(instance=request.user)
    return render(
        request, 'accounts/settings.html', {
            'form':
            formrenderer.render(request,
                                form,
                                title=ugettext("Profilio nustatymai"),
                                submit=ugettext("Saugoti")),
        })
Beispiel #8
0
def project_form(request):
    form_title = ugettext('Pateikti naują projektą')

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(request.POST, frontpage_forms.ProjectForm)
        if form.is_valid():
            queue = frontpage_queues.ProjectDatasetQueue.get(request)
            project = frontpage_helpers.save_project_form(request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(request, ugettext("Projektas „%s“ sėkmingai sukurtas." % project))
                return redirect(project)
    else:
        form = frontpage_forms.ProjectForm()

    return render(request, 'frontpage/project_form.html', {
        'form': formrenderer.render(request, form, title=form_title, submit=ugettext('Pateikti')),
    })
Beispiel #9
0
def project_update(request, agent_slug, project_slug):
    if request.user.is_superuser:
        project = get_object_or_404(core_models.Project, agent__slug=agent_slug, slug=project_slug)
    else:
        project = get_object_or_404(core_models.Project, agent__slug=agent_slug, slug=project_slug, user=request.user)

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(request.POST, frontpage_forms.ProjectForm, instance=project)
        if form.is_valid():
            queue = frontpage_queues.ProjectDatasetQueue.get(request)
            frontpage_helpers.save_project_form(request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(request, ugettext("Projektas „%s“ atnaujintas." % project))
                return redirect(project)
    else:
        form = frontpage_forms.ProjectForm(instance=project)

    return render(request, 'frontpage/project_form.html', {
        'form': formrenderer.render(request, form, title=project.title, submit=ugettext('Pateikti')),
    })
Beispiel #10
0
def dataset_update(request, agent_slug, dataset_slug):
    if request.user.is_superuser:
        dataset = get_object_or_404(core_models.Dataset, agent__slug=agent_slug, slug=dataset_slug)
    else:
        dataset = get_object_or_404(core_models.Dataset, agent__slug=agent_slug, slug=dataset_slug, user=request.user)

    if request.method == 'POST':
        form, agent = frontpage_helpers.get_agent_form(request.POST, frontpage_forms.DatasetForm, instance=dataset)
        if form.is_valid():
            queue = frontpage_queues.DatasetSourceQueue.get(request)
            frontpage_helpers.save_dataset_form(request, form, queue, agent)
            if queue.source.is_active():
                return queue.source.redirect()
            else:
                messages.success(request, ugettext("Duomenų šaltinis „%s“ atnaujintas." % dataset))
                return redirect(dataset)
    else:
        form = frontpage_forms.DatasetForm(instance=dataset)

    return render(request, 'frontpage/dataset_form.html', {
        'form': formrenderer.render(request, form, title=dataset.title, submit=ugettext("Pateikti")),
    })