Skip to content

Commit

Permalink
Add option to make integration active
Browse files Browse the repository at this point in the history
  • Loading branch information
GDay committed Mar 26, 2024
1 parent 0109943 commit cd7a161
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
16 changes: 14 additions & 2 deletions back/admin/integrations/builder_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
from django.contrib.messages.views import SuccessMessageMixin
from django.http import Http404, HttpResponse, HttpResponseRedirect
from django.shortcuts import get_object_or_404, render
from django.urls import reverse
from django.urls import reverse, reverse_lazy
from django.utils.translation import gettext as _
from django.views.generic import View
from django.views.generic.detail import DetailView, SingleObjectMixin
from django.views.generic.edit import CreateView, FormView
from django.views.generic.edit import CreateView, FormView, UpdateView

from admin.integrations.exceptions import (
DataIsNotJSONError,
Expand Down Expand Up @@ -66,6 +66,18 @@ def get_context_data(self, **kwargs):
return context


class IntegrationBuilderMakeActiveUpdateView(
LoginRequiredMixin, AdminPermMixin, UpdateView
):
model = Integration
fields = []
success_url = reverse_lazy("settings:integrations")

def form_valid(self, form):
form.instance.is_active = True
return super().form_valid(form)


class IntegrationBuilderView(LoginRequiredMixin, AdminPermMixin, DetailView):
template_name = "manifest_test.html"
model = Integration
Expand Down
5 changes: 5 additions & 0 deletions back/admin/integrations/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@
name="delete",
),
path("update/<int:pk>/", views.IntegrationUpdateView.as_view(), name="update"),
path(
"make_active/<int:pk>/",
builder_views.IntegrationBuilderMakeActiveUpdateView.as_view(),
name="make_active",
),
path(
"create/google_login/",
views.IntegrationCreateGoogleLoginView.as_view(),
Expand Down
6 changes: 6 additions & 0 deletions back/admin/settings/templates/settings_integrations.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@
<a href="{% url 'integrations:builder-detail' integration.id %}" class="btn btn-primary">
{% translate "Live edit and test integration" %}
</a>
<form action="{% url 'integrations:make_active' integration.id %}" method="post" style="display:inline-block">
{% csrf_token %}
<button class="btn btn-primary" style="float: unset">
{% translate "Make active" %}
</button>
</form>
<a href="{% url 'integrations:delete' integration.id %}" class="btn btn-danger">
{% translate "Remove" %}
</a>
Expand Down

0 comments on commit cd7a161

Please sign in to comment.