Notification emails #80

Merged
Oleg-Komarov merged 31 commits from notifications into main 2024-04-18 16:11:20 +02:00
6 changed files with 34 additions and 9 deletions
Showing only changes of commit b1426e8d5f - Show all commits

View File

@ -0,0 +1,18 @@
# Generated by Django 4.2.11 on 2024-04-18 13:48
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('abuse', '0004_abusereport_rating_abusereport_type'),
]
operations = [
migrations.AlterField(
model_name='abusereport',
name='type',
field=models.PositiveSmallIntegerField(choices=[(1, 'Extension'), (2, 'User'), (3, 'Rating')], default=1),
),
]

View File

@ -8,7 +8,7 @@ from django.urls import reverse
from extended_choices import Choices
from geoip2.errors import GeoIP2Error
from constants.base import ABUSE_TYPE, ABUSE_TYPE_EXTENSION, ABUSE_TYPE_REVIEW
from constants.base import ABUSE_TYPE, ABUSE_TYPE_EXTENSION, ABUSE_TYPE_RATING
from common.model_mixins import CreatedModifiedMixin, TrackChangesMixin, SoftDeleteMixin
import extensions.fields
@ -101,7 +101,7 @@ class AbuseReport(CreatedModifiedMixin, TrackChangesMixin, SoftDeleteMixin, mode
reporter_id=user_id,
extension_id=extension_id,
rating_id=rating_id,
type=ABUSE_TYPE_REVIEW,
type=ABUSE_TYPE_RATING,
).exists()
def get_absolute_url(self):

View File

@ -8,7 +8,7 @@ from django.views.generic.edit import CreateView
from django.shortcuts import get_object_or_404, redirect
from .forms import ReportForm
from constants.base import ABUSE_TYPE_EXTENSION, ABUSE_TYPE_REVIEW
from constants.base import ABUSE_TYPE_EXTENSION, ABUSE_TYPE_RATING
from abuse.models import AbuseReport
from ratings.models import Rating
from extensions.models import Extension, Version
@ -109,7 +109,7 @@ class ReportReviewView(
form.instance.extension = self.extension
form.instance.rating = self.rating
form.instance.extension_version = self.version.version
form.instance.type = ABUSE_TYPE_REVIEW
form.instance.type = ABUSE_TYPE_RATING
return super().form_valid(form)
def get_context_data(self, **kwargs):

View File

@ -212,9 +212,6 @@ class LogEntryAdmin(admin.ModelAdmin):
def has_change_permission(self, request, obj=None):
return False
def has_delete_permission(self, request, obj=None):
return False
def has_view_permission(self, request, obj=None):
return request.user.is_superuser

View File

@ -1,3 +1,4 @@
import logging
import random
from django.core.management.base import BaseCommand
@ -61,6 +62,15 @@ class Command(BaseCommand):
help = 'Generate fake data with extensions, users and versions using test factories.'
def handle(self, *args, **options):
verbosity = int(options['verbosity'])
root_logger = logging.getLogger('root')
if verbosity > 2:
root_logger.setLevel(logging.DEBUG)
elif verbosity > 1:
root_logger.setLevel(logging.INFO)
else:
root_logger.setLevel(logging.WARNING)
tags = {
type_id: list(Tag.objects.filter(type=type_id).values_list('name', flat=True))
for type_id, _ in Extension.TYPES

View File

@ -93,10 +93,10 @@ TEAM_ROLE_CHOICES = (
# Abuse
ABUSE_TYPE_EXTENSION = 1
ABUSE_TYPE_USER = 2
ABUSE_TYPE_REVIEW = 3
ABUSE_TYPE_RATING = 3
ABUSE_TYPE = Choices(
('ABUSE_EXTENSION', ABUSE_TYPE_EXTENSION, "Extension"),
('ABUSE_USER', ABUSE_TYPE_USER, "User"),
('ABUSE_REVIEW', ABUSE_TYPE_REVIEW, "Review"),
('ABUSE_RATING', ABUSE_TYPE_RATING, "Rating"),
)