Delete old user rating functionality

This commit is contained in:
Reckless_Satoshi 2023-05-05 05:40:29 -07:00
parent 4d62ea1549
commit 811cb4181d
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
6 changed files with 3 additions and 68 deletions

View File

@ -342,8 +342,6 @@ class UserRobotAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
"earned_rewards",
"claimed_rewards",
"platform_rating",
"total_ratings",
"avg_rating",
"num_disputes",
"lost_disputes",
)

View File

@ -1567,37 +1567,6 @@ class Logics:
order.save()
return True, None
@classmethod
def rate_counterparty(cls, order, user, rating):
"""
Not in use
"""
rating_allowed_status = [
Order.Status.PAY,
Order.Status.SUC,
Order.Status.FAI,
Order.Status.MLD,
Order.Status.TLD,
]
# If the trade is finished
if order.status in rating_allowed_status:
# if maker, rates taker
if order.maker == user and order.maker_rated is False:
cls.add_robot_rating(order.taker.robot, rating)
order.maker_rated = True
order.save()
# if taker, rates maker
if order.taker == user and order.taker_rated is False:
cls.add_robot_rating(order.maker.robot, rating)
order.taker_rated = True
order.save()
else:
return False, {"bad_request": "You cannot rate your counterparty yet."}
return True, None
@classmethod
def rate_platform(cls, user, rating):
user.robot.platform_rating = rating

View File

@ -2,11 +2,7 @@ from pathlib import Path
from django.conf import settings
from django.contrib.auth.models import User
from django.core.validators import (
MaxValueValidator,
MinValueValidator,
validate_comma_separated_integer_list,
)
from django.core.validators import validate_comma_separated_integer_list
from django.db import models
from django.db.models.signals import post_save, pre_delete
from django.dispatch import receiver
@ -34,23 +30,6 @@ class Robot(models.Model):
# Total trades
total_contracts = models.PositiveIntegerField(null=False, default=0)
# Ratings stored as a comma separated integer list
total_ratings = models.PositiveIntegerField(null=False, default=0)
latest_ratings = models.CharField(
max_length=999,
null=True,
default=None,
validators=[validate_comma_separated_integer_list],
blank=True,
) # Will only store latest rating
avg_rating = models.DecimalField(
max_digits=4,
decimal_places=1,
default=None,
null=True,
validators=[MinValueValidator(0), MaxValueValidator(100)],
blank=True,
)
# Used to deep link telegram chat in case telegram notifications are enabled
telegram_token = models.CharField(max_length=20, null=True, blank=True)
telegram_chat_id = models.BigIntegerField(null=True, default=None, blank=True)

View File

@ -308,15 +308,6 @@ class OrderViewSchema:
respectively. Only when both parties have submitted their
dispute statement, the order status changes to `16` (Waiting
for dispute resolution)
- `rate_user`
- You can rate your counterparty using this action. You can rate
your user from `1-5` using the `rate` field in the request
body. Only allowed in the following states:
- `13` - Sending satoshis to buyer
- `14` - Sucessful trade
- `15` - Failed lightning network routing
- `17` - Maker lost dispute
- `18` - Taker lost dispute
- `rate_platform`
- Let us know how much you love (or hate 😢) RoboSats.
You can rate the platform from `1-5` using the `rate` field in the request body

View File

@ -501,7 +501,6 @@ class UpdateOrderSerializer(serializers.Serializer):
"cancel",
"confirm",
"undo_confirm",
"rate_user",
"rate_platform",
),
allow_null=False,

View File

@ -598,9 +598,8 @@ class OrderView(viewsets.ViewSet):
# 6) If action is rate
elif action == "rate_user" and rating:
valid, context = Logics.rate_counterparty(order, request.user, rating)
if not valid:
return Response(context, status.HTTP_400_BAD_REQUEST)
"""No user rating"""
pass
# 7) If action is rate_platform
elif action == "rate_platform" and rating: