Skip to content

Commit

Permalink
wire up some basic webhook triggering and a profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
lilioid committed Jul 9, 2024
1 parent 266f0aa commit bb10ba4
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/vinywaji/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ def me(self, request):
]
)
)


class TransactionViewSet(
viewsets.mixins.CreateModelMixin,
viewsets.mixins.RetrieveModelMixin,
Expand Down
2 changes: 1 addition & 1 deletion src/vinywaji/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def __str__(self):
return f"Webhook {self.id} (/{self.trigger_key})"

def get_absolute_url(self) -> str:
return reverse("webhook-trigger", kwargs={"pk": self.pk})
return reverse("webhook-trigger", kwargs={"trigger": self.trigger_key})

def trigger(self) -> Transaction:
"""
Expand Down
1 change: 1 addition & 0 deletions src/vinywaji/gui/templates/components/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{% if request.user.is_anonymous %}
<li><a href="{% url 'simple_openid_connect:login' %}">Login</a></li>
{% else %}
<li><a href="{% url 'profile' %}">Profile</a></li>
<li><a href="{% url 'simple_openid_connect:logout' %}">Logout</a></li>
{% endif %}
</ul>
Expand Down
21 changes: 21 additions & 0 deletions src/vinywaji/gui/templates/views/profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{% extends "base.html" %}
{% load static %}

{% block authorized-content %}
<h4>Profile Settings</h4>

<section>
<h5>Basic Information</h5>
<div>
<span>Username:</label>
<span>{{ request.user }} </span>
</div>
</section>

<section>
<h5>Webhooks</h5>
<div>
TODO: Put webhook configuration here
</div>
</section>
{% endblock %}
2 changes: 2 additions & 0 deletions src/vinywaji/gui/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@

urlpatterns = [
path("", views.DashboardView.as_view(), name="dashboard"),
path("profile/", views.ProfileView.as_view(), name="profile"),
path("webhook/<str:trigger>", views.WebhookTriggerView.as_view(), name="webhook-trigger"),
path("manifest.json", views.manifest, name="manifest"),
]
19 changes: 19 additions & 0 deletions src/vinywaji/gui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
from django.views import View
from django.contrib.auth.mixins import LoginRequiredMixin


class DashboardView(View):
Expand All @@ -29,6 +30,24 @@ def get(self, request: HttpRequest):
return render(request, "views/dashboard.html", context)


class ProfileView(LoginRequiredMixin, View):
def get(self, request: HttpRequest):
context = {
"openid_provider_name": settings.OPENID_PROVIDER_NAME,
"mafiasi_colors": settings.MAFIASI_COLORS,
"title": settings.ORG_NAME,
}
if not request.user.is_anonymous:
context.update({})

return render(request, "views/profile.html", context)


class WebhookTriggerView(View):
def get(self, request: HttpRequest, trigger: str):
return HttpResponse("OK")


def manifest(request):
if settings.MAFIASI_COLORS:
theme_color = "#02837c"
Expand Down

0 comments on commit bb10ba4

Please sign in to comment.