From 422e6d43e46da4802093577d31aaa405c450aa47 Mon Sep 17 00:00:00 2001 From: VIBR0X <44766005+vedant-github@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:09:20 +0530 Subject: [PATCH 1/2] add migration --- bans/migrations/0004_auto_20231024_1619.py | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 bans/migrations/0004_auto_20231024_1619.py diff --git a/bans/migrations/0004_auto_20231024_1619.py b/bans/migrations/0004_auto_20231024_1619.py new file mode 100644 index 00000000..8e674fa2 --- /dev/null +++ b/bans/migrations/0004_auto_20231024_1619.py @@ -0,0 +1,25 @@ +# Generated by Django 3.2.16 on 2023-10-24 10:49 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0040_remove_userprofile_followed_communities'), + ('bans', '0003_alter_ssoban_banned_by'), + ] + + operations = [ + migrations.AddField( + model_name='ssoban', + name='banned_user_ldapid', + field=models.CharField(blank=True, max_length=20, null=True), + ), + migrations.AlterField( + model_name='ssoban', + name='banned_user', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='banned_user', to='users.userprofile'), + ), + ] From 476d4728f90801c86d3477f9207ff47963144948 Mon Sep 17 00:00:00 2001 From: VIBR0X <44766005+vedant-github@users.noreply.github.com> Date: Wed, 25 Oct 2023 11:24:17 +0530 Subject: [PATCH 2/2] lint fix --- bans/migrations/0004_auto_20231024_1619.py | 21 +++++++++++++-------- bans/models.py | 2 -- buyandsell/views.py | 12 ++++++------ locations/management/commands/mapnav.py | 1 - 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/bans/migrations/0004_auto_20231024_1619.py b/bans/migrations/0004_auto_20231024_1619.py index 8e674fa2..8178cb43 100644 --- a/bans/migrations/0004_auto_20231024_1619.py +++ b/bans/migrations/0004_auto_20231024_1619.py @@ -5,21 +5,26 @@ class Migration(migrations.Migration): - dependencies = [ - ('users', '0040_remove_userprofile_followed_communities'), - ('bans', '0003_alter_ssoban_banned_by'), + ("users", "0040_remove_userprofile_followed_communities"), + ("bans", "0003_alter_ssoban_banned_by"), ] operations = [ migrations.AddField( - model_name='ssoban', - name='banned_user_ldapid', + model_name="ssoban", + name="banned_user_ldapid", field=models.CharField(blank=True, max_length=20, null=True), ), migrations.AlterField( - model_name='ssoban', - name='banned_user', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='banned_user', to='users.userprofile'), + model_name="ssoban", + name="banned_user", + field=models.ForeignKey( + blank=True, + null=True, + on_delete=django.db.models.deletion.CASCADE, + related_name="banned_user", + to="users.userprofile", + ), ), ] diff --git a/bans/models.py b/bans/models.py index 4f8ffac2..047d2cb8 100644 --- a/bans/models.py +++ b/bans/models.py @@ -1,8 +1,6 @@ -from collections.abc import Iterable from django.db import models from uuid import uuid4 from users.models import UserProfile -from django.db.models.signals import post_save, post_delete, pre_save # Create your models here. diff --git a/buyandsell/views.py b/buyandsell/views.py index 346076ef..4d886a30 100644 --- a/buyandsell/views.py +++ b/buyandsell/views.py @@ -7,12 +7,11 @@ from roles.helpers import login_required_ajax from buyandsell.models import Ban, Category, ImageURL, Limit, Product, Report from buyandsell.serializers import ProductSerializer -from helpers.misc import query_from_num, query_search +from helpers.misc import query_search from users.models import UserProfile from django.db.models import Q import json from django.utils import timezone -import traceback REPORTS_THRES = 3 @@ -24,7 +23,8 @@ class BuyAndSellViewSet(viewsets.ModelViewSet): def mail_moderator(self, report: Report): msg = f""" - {str(report.reporter)} lodged a report against the product {str(report.product)} posted by {str(report.product.user)}. + {str(report.reporter)} lodged a report against the product + {str(report.product)} posted by {str(report.product.user)}. Alleged Reason: {report.reason}.""" send_mail( "New Report", msg, settings.DEFAULT_FROM_EMAIL, [report.moderator_email] @@ -36,7 +36,7 @@ def update_limits(self): limit.delete() def update_bans(self, product: Product = None): - if product != None: + if product is not None: """Get the existing reports on this product that have been accepted by the moderator but have not been addressed (by initiating a ban).""" reports = Report.objects.filter( @@ -74,7 +74,7 @@ def seller_filter(self, request, queryset): return queryset def list(self, request): - ##introduce tags? + # introduce tags? self.update_bans() queryset = self.queryset.filter(status=True) """remove products from banned users""" @@ -157,7 +157,7 @@ def get_product(self, pk): @login_required_ajax def update(self, request, pk): product = self.get_product(pk) - ##TO TEST: + # TO TEST: # product.category.numproducts-=1 # product.category.numproducts-=1 if product.user == UserProfile.objects.get(user=request.user): diff --git a/locations/management/commands/mapnav.py b/locations/management/commands/mapnav.py index 5ca89938..56e83829 100644 --- a/locations/management/commands/mapnav.py +++ b/locations/management/commands/mapnav.py @@ -4,7 +4,6 @@ import sys from locations.serializers import LocationSerializerMin from locations.models import Location -import json # class ProfileFetcher(): # """Helper to get dictionary of profiles efficiently."""