Skip to content

Commit

Permalink
Merge pull request #505 from Krishna-Baldwa/'stable-bans'
Browse files Browse the repository at this point in the history
add migration in bans
  • Loading branch information
VIBR0X authored Oct 25, 2023
2 parents 3ae2894 + 476d472 commit ea2b18e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 9 deletions.
30 changes: 30 additions & 0 deletions bans/migrations/0004_auto_20231024_1619.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# 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",
),
),
]
2 changes: 0 additions & 2 deletions bans/models.py
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
12 changes: 6 additions & 6 deletions buyandsell/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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]
Expand All @@ -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(
Expand Down Expand Up @@ -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"""
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion locations/management/commands/mapnav.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down

0 comments on commit ea2b18e

Please sign in to comment.