06/16 Phase 6
This commit is contained in:
@@ -7,6 +7,7 @@ from app.models.listing import Listing, ListingImage
|
||||
from app.models.geo import ZipGeo, Metro
|
||||
from app.models.messaging import Conversation, Message
|
||||
from app.models.favorite import Favorite
|
||||
from app.models.report import Report
|
||||
from app.models.payments import Subscription, Transaction, Boost
|
||||
from app.models.ads import Ad, Sponsor, PromotedKeyword
|
||||
from app.models.audit import AuditLog
|
||||
@@ -14,5 +15,5 @@ from app.models.setting import Setting
|
||||
|
||||
__all__ = ["Plan", "User", "TrustEvent", "Category", "Listing",
|
||||
"ListingImage", "ZipGeo", "Metro", "Conversation", "Message",
|
||||
"Favorite", "Subscription", "Transaction", "Boost",
|
||||
"Favorite", "Report", "Subscription", "Transaction", "Boost",
|
||||
"Ad", "Sponsor", "PromotedKeyword", "AuditLog", "Setting"]
|
||||
|
||||
@@ -42,3 +42,12 @@ class Lang(str, enum.Enum):
|
||||
en = "en"
|
||||
vi = "vi"
|
||||
es = "es"
|
||||
|
||||
|
||||
class ReportReason(str, enum.Enum):
|
||||
spam = "spam"
|
||||
scam = "scam"
|
||||
offensive = "offensive"
|
||||
duplicate = "duplicate"
|
||||
miscategorized = "miscategorized"
|
||||
other = "other"
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
"""User-submitted reports against listings (spam/abuse moderation)."""
|
||||
from datetime import datetime
|
||||
from app.extensions import db
|
||||
from app.models.enums import ReportReason
|
||||
|
||||
|
||||
class Report(db.Model):
|
||||
__tablename__ = "reports"
|
||||
|
||||
id = db.Column(db.BigInteger().with_variant(db.Integer, "sqlite"),
|
||||
primary_key=True, autoincrement=True)
|
||||
listing_id = db.Column(db.BigInteger().with_variant(db.Integer, "sqlite"),
|
||||
db.ForeignKey("listings.id"), nullable=False, index=True)
|
||||
reporter_id = db.Column(db.BigInteger().with_variant(db.Integer, "sqlite"),
|
||||
db.ForeignKey("users.id"), nullable=False, index=True)
|
||||
reason = db.Column(db.Enum(ReportReason), nullable=False)
|
||||
note = db.Column(db.Text, nullable=True)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
listing = db.relationship("Listing", backref=db.backref("reports", lazy="dynamic"))
|
||||
reporter = db.relationship("User", backref=db.backref("reports_filed", lazy="dynamic"))
|
||||
|
||||
__table_args__ = (
|
||||
db.UniqueConstraint("reporter_id", "listing_id", name="uq_report_reporter_listing"),
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Report L{self.listing_id} by u{self.reporter_id} {self.reason.value}>"
|
||||
Reference in New Issue
Block a user