mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 20:21:35 +00:00
Delete old user rating functionality
This commit is contained in:
parent
4d62ea1549
commit
811cb4181d
@ -342,8 +342,6 @@ class UserRobotAdmin(AdminChangeLinksMixin, admin.ModelAdmin):
|
|||||||
"earned_rewards",
|
"earned_rewards",
|
||||||
"claimed_rewards",
|
"claimed_rewards",
|
||||||
"platform_rating",
|
"platform_rating",
|
||||||
"total_ratings",
|
|
||||||
"avg_rating",
|
|
||||||
"num_disputes",
|
"num_disputes",
|
||||||
"lost_disputes",
|
"lost_disputes",
|
||||||
)
|
)
|
||||||
|
@ -1567,37 +1567,6 @@ class Logics:
|
|||||||
order.save()
|
order.save()
|
||||||
return True, None
|
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
|
@classmethod
|
||||||
def rate_platform(cls, user, rating):
|
def rate_platform(cls, user, rating):
|
||||||
user.robot.platform_rating = rating
|
user.robot.platform_rating = rating
|
||||||
|
@ -2,11 +2,7 @@ from pathlib import Path
|
|||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from django.core.validators import (
|
from django.core.validators import validate_comma_separated_integer_list
|
||||||
MaxValueValidator,
|
|
||||||
MinValueValidator,
|
|
||||||
validate_comma_separated_integer_list,
|
|
||||||
)
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.signals import post_save, pre_delete
|
from django.db.models.signals import post_save, pre_delete
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
@ -34,23 +30,6 @@ class Robot(models.Model):
|
|||||||
# Total trades
|
# Total trades
|
||||||
total_contracts = models.PositiveIntegerField(null=False, default=0)
|
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
|
# Used to deep link telegram chat in case telegram notifications are enabled
|
||||||
telegram_token = models.CharField(max_length=20, null=True, blank=True)
|
telegram_token = models.CharField(max_length=20, null=True, blank=True)
|
||||||
telegram_chat_id = models.BigIntegerField(null=True, default=None, blank=True)
|
telegram_chat_id = models.BigIntegerField(null=True, default=None, blank=True)
|
||||||
|
@ -308,15 +308,6 @@ class OrderViewSchema:
|
|||||||
respectively. Only when both parties have submitted their
|
respectively. Only when both parties have submitted their
|
||||||
dispute statement, the order status changes to `16` (Waiting
|
dispute statement, the order status changes to `16` (Waiting
|
||||||
for dispute resolution)
|
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`
|
- `rate_platform`
|
||||||
- Let us know how much you love (or hate 😢) RoboSats.
|
- 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
|
You can rate the platform from `1-5` using the `rate` field in the request body
|
||||||
|
@ -501,7 +501,6 @@ class UpdateOrderSerializer(serializers.Serializer):
|
|||||||
"cancel",
|
"cancel",
|
||||||
"confirm",
|
"confirm",
|
||||||
"undo_confirm",
|
"undo_confirm",
|
||||||
"rate_user",
|
|
||||||
"rate_platform",
|
"rate_platform",
|
||||||
),
|
),
|
||||||
allow_null=False,
|
allow_null=False,
|
||||||
|
@ -598,9 +598,8 @@ class OrderView(viewsets.ViewSet):
|
|||||||
|
|
||||||
# 6) If action is rate
|
# 6) If action is rate
|
||||||
elif action == "rate_user" and rating:
|
elif action == "rate_user" and rating:
|
||||||
valid, context = Logics.rate_counterparty(order, request.user, rating)
|
"""No user rating"""
|
||||||
if not valid:
|
pass
|
||||||
return Response(context, status.HTTP_400_BAD_REQUEST)
|
|
||||||
|
|
||||||
# 7) If action is rate_platform
|
# 7) If action is rate_platform
|
||||||
elif action == "rate_platform" and rating:
|
elif action == "rate_platform" and rating:
|
||||||
|
Loading…
Reference in New Issue
Block a user