mirror of
https://github.com/jlengrand/bugsink.git
synced 2026-03-10 08:01:17 +00:00
project_id => project_pk, at least in urls and view signatures
some consistency
This commit is contained in:
@@ -16,10 +16,10 @@ def login_exempt(view):
|
||||
def project_membership_required(function):
|
||||
@wraps(function)
|
||||
def wrapper(request, *args, **kwargs):
|
||||
if "project_id" not in kwargs:
|
||||
raise TypeError("project_id must be passed as a keyword argument")
|
||||
project_id = kwargs.pop("project_id")
|
||||
project = get_object_or_404(Project, pk=project_id)
|
||||
if "project_pk" not in kwargs:
|
||||
raise TypeError("project_pk must be passed as a keyword argument")
|
||||
project_pk = kwargs.pop("project_pk")
|
||||
project = get_object_or_404(Project, pk=project_pk)
|
||||
kwargs["project"] = project
|
||||
if project.users.filter(pk=request.user.pk).exists():
|
||||
return function(request, *args, **kwargs)
|
||||
|
||||
@@ -3,7 +3,7 @@ from django.urls import path
|
||||
from .views import IngestEventAPIView, IngestEnvelopeAPIView
|
||||
|
||||
urlpatterns = [
|
||||
# project_id has to be an int per Sentry Client expectations.
|
||||
path("<int:project_id>/store/", IngestEventAPIView.as_view()),
|
||||
path("<int:project_id>/envelope/", IngestEnvelopeAPIView.as_view()),
|
||||
# project_pk has to be an int per Sentry Client expectations.
|
||||
path("<int:project_pk>/store/", IngestEventAPIView.as_view()),
|
||||
path("<int:project_pk>/envelope/", IngestEnvelopeAPIView.as_view()),
|
||||
]
|
||||
|
||||
@@ -54,12 +54,12 @@ class BaseIngestAPIView(APIView):
|
||||
raise exceptions.NotAuthenticated("Unable to find authentication information")
|
||||
|
||||
@classmethod
|
||||
def get_project(cls, request, project_id):
|
||||
def get_project(cls, request, project_pk):
|
||||
# NOTE this gives a 404 for non-properly authorized. Is this really something we care about, i.e. do we want to
|
||||
# raise NotAuthenticated? In that case we need to get the project first, and then do a constant-time-comp on the
|
||||
# sentry_key
|
||||
sentry_key = cls.get_sentry_key_for_request(request)
|
||||
return get_object_or_404(Project, pk=project_id, sentry_key=sentry_key)
|
||||
return get_object_or_404(Project, pk=project_pk, sentry_key=sentry_key)
|
||||
|
||||
@classmethod
|
||||
def process_event(cls, event_data, project, request, now=None):
|
||||
@@ -164,8 +164,8 @@ class BaseIngestAPIView(APIView):
|
||||
|
||||
class IngestEventAPIView(BaseIngestAPIView):
|
||||
|
||||
def post(self, request, project_id=None):
|
||||
project = self.get_project(request, project_id)
|
||||
def post(self, request, project_pk=None):
|
||||
project = self.get_project(request, project_pk)
|
||||
|
||||
self.process_event(request.data, project, request)
|
||||
return Response()
|
||||
@@ -174,8 +174,8 @@ class IngestEventAPIView(BaseIngestAPIView):
|
||||
class IngestEnvelopeAPIView(BaseIngestAPIView):
|
||||
parser_classes = [EnvelopeParser]
|
||||
|
||||
def post(self, request, project_id=None):
|
||||
project = self.get_project(request, project_id)
|
||||
def post(self, request, project_pk=None):
|
||||
project = self.get_project(request, project_pk)
|
||||
|
||||
data = request.data # make this a local var to ensure it's sent as part of capture_stacktrace(..)
|
||||
if len(data) < 3:
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
|
||||
<div class="flex bg-slate-50 border-b-2 mt-4 items-end">
|
||||
<div class="flex">
|
||||
<a href="{% url "issue_list_open" project_id=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "open" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-b-4 hover:border-slate-400{% endif %}">Open</div></a>
|
||||
<a href="{% url "issue_list_unresolved" project_id=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "unresolved" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-b-4 hover:border-slate-400{% endif %}">Unresolved</div></a>
|
||||
<a href="{% url "issue_list_muted" project_id=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "muted" %}text-cyan-500 border-cyan-500 border-b-4{% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">Muted</div></a>
|
||||
<a href="{% url "issue_list_resolved" project_id=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "resolved" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">Resolved</div></a>
|
||||
<a href="{% url "issue_list_all" project_id=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "all" %}text-cyan-500 border-cyan-500 border-b-4{% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">All</div></a>
|
||||
<a href="{% url "issue_list_open" project_pk=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "open" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-b-4 hover:border-slate-400{% endif %}">Open</div></a>
|
||||
<a href="{% url "issue_list_unresolved" project_pk=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "unresolved" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-b-4 hover:border-slate-400{% endif %}">Unresolved</div></a>
|
||||
<a href="{% url "issue_list_muted" project_pk=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "muted" %}text-cyan-500 border-cyan-500 border-b-4{% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">Muted</div></a>
|
||||
<a href="{% url "issue_list_resolved" project_pk=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "resolved" %}text-cyan-500 border-cyan-500 border-b-4 {% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">Resolved</div></a>
|
||||
<a href="{% url "issue_list_all" project_pk=project.id %}"><div class="p-4 font-bold hover:bg-slate-200 {% if state_filter == "all" %}text-cyan-500 border-cyan-500 border-b-4{% else %}text-slate-500 hover:border-slate-400 hover:border-b-4{% endif %}">All</div></a>
|
||||
</div>
|
||||
<div class="ml-auto p-2">
|
||||
<input type="text" name="search" placeholder="search issues..." class="focus:border-cyan-500 focus:ring-cyan-200 rounded-md"/>
|
||||
|
||||
@@ -5,11 +5,11 @@ from .views import (
|
||||
issue_grouping)
|
||||
|
||||
urlpatterns = [
|
||||
path('<int:project_id>/', issue_list, {"state_filter": "open"}, name="issue_list_open"),
|
||||
path('<int:project_id>/unresolved', issue_list, {"state_filter": "unresolved"}, name="issue_list_unresolved"),
|
||||
path('<int:project_id>/resolved/', issue_list, {"state_filter": "resolved"}, name="issue_list_resolved"),
|
||||
path('<int:project_id>/muted/', issue_list, {"state_filter": "muted"}, name="issue_list_muted"),
|
||||
path('<int:project_id>/all/', issue_list, {"state_filter": "all"}, name="issue_list_all"),
|
||||
path('<int:project_pk>/', issue_list, {"state_filter": "open"}, name="issue_list_open"),
|
||||
path('<int:project_pk>/unresolved', issue_list, {"state_filter": "unresolved"}, name="issue_list_unresolved"),
|
||||
path('<int:project_pk>/resolved/', issue_list, {"state_filter": "resolved"}, name="issue_list_resolved"),
|
||||
path('<int:project_pk>/muted/', issue_list, {"state_filter": "muted"}, name="issue_list_muted"),
|
||||
path('<int:project_pk>/all/', issue_list, {"state_filter": "all"}, name="issue_list_all"),
|
||||
|
||||
path('issue/<uuid:issue_pk>/event/<uuid:event_pk>/', issue_event_stacktrace),
|
||||
path('issue/<uuid:issue_pk>/event/<uuid:event_pk>/details/', issue_event_details),
|
||||
|
||||
Reference in New Issue
Block a user