Post Web Assets v2 upgrade UI fixes and improvements #114
@ -10,7 +10,7 @@ import abuse.models
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ReportForm(forms.ModelForm):
|
||||
class ReportExtensionForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = abuse.models.AbuseReport
|
||||
fields = ('reason', 'version', 'message')
|
||||
@ -35,3 +35,9 @@ class ReportForm(forms.ModelForm):
|
||||
return compare.version(self.cleaned_data[field])
|
||||
except ValidationError as e:
|
||||
self.add_error(field, forms.ValidationError([e.message], code='invalid'))
|
||||
|
||||
|
||||
class ReportRatingForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = abuse.models.AbuseReport
|
||||
fields = ('reason', 'message')
|
||||
|
@ -18,7 +18,7 @@ urlpatterns = [
|
||||
),
|
||||
path(
|
||||
'<slug:slug>/<str:version>/<int:rating>/report/',
|
||||
views.ReportReviewView.as_view(),
|
||||
views.ReportRatingView.as_view(),
|
||||
name='report-ratings',
|
||||
),
|
||||
],
|
||||
|
@ -7,7 +7,7 @@ from django.views.generic.list import ListView
|
||||
from django.views.generic.edit import CreateView
|
||||
from django.shortcuts import get_object_or_404, redirect
|
||||
|
||||
from .forms import ReportForm
|
||||
from .forms import ReportExtensionForm, ReportRatingForm
|
||||
from constants.base import ABUSE_TYPE_EXTENSION, ABUSE_TYPE_RATING
|
||||
from abuse.models import AbuseReport
|
||||
from ratings.models import Rating
|
||||
@ -40,7 +40,7 @@ class ReportExtensionView(
|
||||
CreateView,
|
||||
):
|
||||
model = AbuseReport
|
||||
form_class = ReportForm
|
||||
form_class = ReportExtensionForm
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
extension = get_object_or_404(Extension.objects.listed, slug=self.kwargs['slug'])
|
||||
@ -69,14 +69,14 @@ class ReportExtensionView(
|
||||
return self.object.get_absolute_url()
|
||||
|
||||
|
||||
class ReportReviewView(
|
||||
class ReportRatingView(
|
||||
LoginRequiredMixin,
|
||||
extensions.views.mixins.ListedExtensionMixin,
|
||||
UserPassesTestMixin,
|
||||
CreateView,
|
||||
):
|
||||
model = AbuseReport
|
||||
form_class = ReportForm
|
||||
form_class = ReportRatingForm
|
||||
|
||||
def test_func(self) -> bool:
|
||||
# TODO: best to redirect to existing report or show a friendly message
|
||||
|
Loading…
Reference in New Issue
Block a user