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