Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.db import models
- from django.db import models
- from django.contrib.contenttypes.fields import GenericForeignKey
- from django.contrib.contenttypes.models import ContentType
- # Create your models here.
- # користувачі платформи +
- class Users(models.Model):
- name = models.CharField(max_length=100, null=True, blank=True, unique=True)
- password_hash = models.CharField(max_length=64, default="")
- email = models.CharField(max_length=100, null=True, blank=True, unique=True)
- self_description = models.TextField(default="")
- current_location_lat = models.FloatField(default=None)
- current_location_long = models.FloatField(default=None)
- last_time_visited = models.DateTimeField(auto_now_add=True)
- role = models.CharField(max_length=6, default="simple") # admin vip
- show_profile_for_all = models.BooleanField(default=True)
- is_blocked_by_admin = models.BooleanField(default=False)
- class Meta:
- ordering = ["name"]
- # /users /users/profiles/<:user_id>
- # теги оголошень, що використовуються для їх опису
- class ProposalsTags(models.Model):
- title = models.CharField(max_length=256, null=True, blank=True, unique=True)
- class Meta:
- ordering = ["title"]
- # фото для опису містять хешкоди щоб уникати дублікатів
- class Images(models.Model):
- path = models.FileField(upload_to='documents/%Y/%m/%d',default=None)
- uploader_user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- time_uploaded = models.DateTimeField(auto_now_add=True)
- image_hash = models.CharField(max_length=77, default="")
- class Meta:
- ordering = ["uploader_user_id", "time_uploaded"]
- unique_together = ["uploader_user_id", "image_hash"]
- # редагування, видалення оглошення програмно можливе коли немає затверджених запитів купівлі, оренди, обміну
- # редагування, видалення програмно неможливе, якщо є назадоволений запит клієнта (непогоджений),
- # його можна зробити невидимим для при пошуку
- # чи є погодженні запити купівлі, оренди, обміну
- # якщо оголошення погодженно можна створити нове оголошення на основі цього яке б ви хотіли редагувати
- # і вже його редагувати
- # оголошення
- class Proposals(models.Model):
- title = models.CharField(max_length=150, default="")
- description = models.TextField(default="")
- images = models.ManyToManyField('Images', blank=True, related_name='proposals_images')
- search_tags = models.ManyToManyField('ProposalsTags', blank=True, related_name='proposals_tags')
- creation_time = models.DateTimeField(auto_now_add=True)
- creator_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- proposal_type = models.CharField(max_length=8, default="sell") # "SELL" "RENT" "EXCHANGE"
- proposal_item_type = models.CharField(max_length=8, default="goods") # "SERVICES" "GOODS"
- proposal_item_state = models.CharField(max_length=4, default="new") # "NEW" "USED"
- proposal_location_latitude = models.FloatField(default=None)
- proposal_location_longitude = models.FloatField(default=None)
- available_items = models.IntegerField(default=1)
- total_items = models.IntegerField(default=1)
- set_email_notification = models.BooleanField(default=True)
- set_visible_for_all = models.BooleanField(default=True)
- is_blocked_by_admin = models.BooleanField(default=False)
- ad_item_description_content_hashcode = models.CharField(max_length=77,
- default="") # хешкод головних даних оголошення для уникнення несанкціонованої зміни інформації оголошення
- class Meta:
- ordering = ["creator_id", "title"]
- unique_together = ["title", "creator_id", "set_visible_for_all"]
- # /advertisements /advertisements/<:ad_id> /advertisements/users/<:user_id> /advertisements/goods/<:ad_type>
- # /advertisements/goods/<:state> /advertisements/services/<:ad_type>
- # опис бажаних умов продажу для SELL/AUCTION
- # опис бажаних умов відданя товару чи послуги
- class ProposalsItemsGetConditions(models.Model):
- proposal_id = models.OneToOneField(Proposals, on_delete=models.CASCADE, default=None)
- description = models.TextField(default="")
- rent_time_unit_measure = models.CharField(max_length=6,
- default="minute") # "MINUTE","HOUR","DAY","MONTH","YEAR" ЯКЩО ОРЕНДА
- item_price_value = models.FloatField(default=1)
- item_price_currency = models.CharField(max_length=3, default="uah") # USD EUR
- wished_items = models.ManyToManyField('DesiredItemsQueries', blank=True, related_name='desired_items')
- #
- # дистанції між користувачем і місця оголощень якщо їхні локації встановлені
- class UsersProposalsLocationsDistances(models.Model):
- proposal_id = models.ForeignKey(Proposals, on_delete=models.CASCADE)
- user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- distance_in_km = models.FloatField(default=0.0)
- class Meta:
- unique_together = ("proposal_id", "user_id")
- ordering = ["user_id"]
- # /advertisements/user/distances/<:user_id>
- # /users/advertisement/distances/<:ad_id>
- # збережені оголошення
- class FavoriteProposals(models.Model):
- favorite_proposal_id = models.ForeignKey(Proposals, on_delete=models.CASCADE)
- user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- added_to_favorite_time = models.DateTimeField(auto_now_add=True)
- description = models.TextField(default="")
- visible_for_others = models.BooleanField(default=False) # щоб інші могли запоропонувати це тобі бачачи що ти б це хотів
- class Meta:
- unique_together = ("favorite_proposal_id", "user_id")
- ordering = ["user_id"]
- # /favorite/users/advertisements/ #/favorite/user/advertisements/<:user_id>
- # запит на бажане оголошення що моніторитиметься
- class DesiredItemsQueries(models.Model):
- query_creator_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- query_description_text = models.TextField(default="")
- query_description_tags = models.ManyToManyField('DesiredItemsDescriptionTags', blank=True,
- related_name='desire_item_description_tags')
- proposal_type = models.CharField(max_length=10,
- default="sell") # ("SE", "SELL"), ("RE", "RENT"), ("EX", "EXCHANGE"),("NM", "NO MATTER")
- proposal_item_type = models.CharField(max_length=10,
- default="goods") # ("GO", "GOODS"),("SE", "SERVICE"),("NM", "NO MATTER")
- proposal_item_state = models.CharField(max_length=10,
- default="new") # ("N", "NEW"),("U", "USED"),("NM", "NO_MATTER")
- notify_on_email = models.BooleanField(default=True)
- query_creation_time = models.DateTimeField(auto_now_add=True)
- visible_for_others = models.BooleanField(
- default=False) # щоб інші могли запоропонувати це тобі бачачи що ти б це хотів видно якщо віп
- # users/desired/advertisements users/desired/advertisements/<:user_id>
- # users/desired/sell/advertisements users/desired/sell/advertisements/<:category_type>
- # users/desired/sell/advertisements/<:category_type>
- # теги для опису бажаного товару чи послуги
- class DesiredItemsDescriptionTags(models.Model):
- title = models.CharField(max_length=256, unique=True, null=True, blank=True)
- class Meta:
- ordering = ["title"]
- # повідомлення від системи про наявність бажаного обєкта за критерыями описаного в оголошенні
- class DesiredItemExistenceNotifications(models.Model):
- query_id = models.ForeignKey(DesiredItemsQueries, on_delete=models.CASCADE,default=None)
- proposal_id = models.ForeignKey(Proposals, on_delete=models.CASCADE,default=None)
- notification_time = models.DateTimeField(auto_now_add=True)
- class Meta:
- ordering = ["query_id"]
- # users/desired/advertisements/notifications/<:user_id>
- class ProposalsItemsRequests(models.Model):
- request_user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- request_type = models.CharField(max_length=10, default="sell") # Sell Exchange Rent
- request_message = models.TextField(default="")
- requested_items = models.ManyToManyField('PossibleItems',
- related_name='requested_items') # робити перевірку чи дані
- suggested_items = models.ManyToManyField('PossibleItems', blank=True,
- related_name='suggested_items') # елементи вже не використані
- request_time = models.DateTimeField(auto_now_add=True)
- request_watched = models.DateTimeField(default=None)
- request_deadline_for_answer = models.DateTimeField(default=None)
- request_subject_done = models.DateTimeField(default=None) # чи виконане за реквастом
- notify_on_email = models.BooleanField(default=True)
- confirm_requested_subject_get_action = models.DateTimeField(default=None)
- request_info_hashcode = models.CharField(max_length=77, default="") # ad_item_description_content_hashcode + count
- class Meta:
- ordering = ["request_user_id"]
- class PossibleItems(models.Model):
- rent_time_unit_measure = models.CharField(max_length=6,
- default="day") # ("MINUTE"),("HOUR"),("DAY"),("MONTH"),("YEAR") якщо потрібно
- rent_time_unit_count = models.IntegerField(default=0)
- proposal_item_count = models.IntegerField(default=1)
- proposal_item_id = models.ForeignKey(Proposals, on_delete=models.CASCADE)
- confirmed_by_another_time = models.DateTimeField(default=None)
- info_hashcode = models.CharField(max_length=77)
- class Meta:
- unique_together = ("proposal_item_id", "proposal_item_count", "rent_time_unit_count", "rent_time_unit_measure")
- #gen
- # запропоновані гроші для оренди
- class AdditionalRequestsOffers(models.Model):
- exchange_type = models.CharField(max_length=15, default="exchange") # ( "SIMPLE EXCHANGE"),("CHAIN EXCHANGE") ("Rent")
- description = models.TextField(default="")
- request_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE,default=None)
- object_id = models.PositiveIntegerField(default=None)
- content_object = GenericForeignKey('request_content_type', 'object_id')
- suggested_price = models.FloatField(default=1)
- suggested_currency = models.CharField(max_length=3, default="uah")
- offer_type = models.CharField(max_length=15, default="want give") # "WANT GIVE" "WANT RECEIVE"
- offer_time = models.DateTimeField(auto_now_add=True)
- # відповідь можливому покупцю на запит купівлі
- class ProposalItemsRequestsAnswers(models.Model):
- request_id = models.ForeignKey(ProposalsItemsRequests, on_delete=models.CASCADE)
- accept_request = models.BooleanField(default=True)
- answer_message = models.TextField(default="")
- answer_time = models.DateTimeField(auto_now_add=True)
- answer_watched = models.DateTimeField(default=None)
- approve_deadline_for_requested_user = models.DateTimeField(default=None)
- approve_accepted_time_for_requested_user = models.DateTimeField(
- default=None) # той хто швидше погодить якщо морочить голову робиться запит до адміна щоб обмежив його дії
- confirm_requested_subject_give_action = models.DateTimeField(default=None)
- # users/requests/buy/answers/<:buy_request_id> users/requests/buy/answers/
- # згенерований можливий ланцюговий обмін ДУМАЙ
- class PossibleChainExchangeProposals(models.Model):
- chain_exchange_id = models.IntegerField()
- user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- chain_exchange_proposal_items = models.ManyToManyField('PossibleItems', blank=True,
- related_name="items_for_chain_exchange") # елементи які пропонуються для обміну
- creation_time = models.DateTimeField(auto_now_add=True)
- previous_block_info_hashcode = models.CharField(max_length=77, default="") # sha3
- exchange_approve = models.DateTimeField(default=None)
- class ChainExchangeProposalsAnswers(models.Model):
- chain_exchange_block_id = models.ForeignKey(PossibleChainExchangeProposals, on_delete=models.CASCADE)
- accept_exchange_conditions = models.BooleanField(default=True)
- answer_message = models.TextField(default="") # відповідь на запропоновані речі для обміну
- answer_time = models.DateTimeField(auto_now_add=True)
- answer_next_chain_exchanger_watched = models.DateTimeField(default=None)
- answer_deadline_for_next_chain_exchanger = models.DateTimeField(default=None)
- #gen
- class ExchangeWishes(models.Model): #ProposalItemsRequestsAnswers
- exchange_type = models.CharField(max_length=15, default="exchange") # chain exchange
- exchange_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, default=None)
- object_id = models.PositiveIntegerField(default=None)
- content_object = GenericForeignKey('exchange_content_type', 'object_id')
- wanted_items_for_chain_exchange = models.ManyToManyField('PossibleItems', blank=True,
- related_name='wanted_items_for_chain_exchange')
- answer_message = models.TextField(default="")
- answer_time = models.DateTimeField(auto_now_add=True)
- answer_watched = models.DateTimeField(default=None)
- approve_deadline_for_previous = models.DateTimeField(default=None)
- approve_accepted = models.DateTimeField(default=None)
- #gen
- class FinishingRankings(models.Model):
- ranking_subject_type = models.CharField(max_length=15, default="sell") #exchange "chain exchange" "rent" "sell"
- request_ranking_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE,default=None) #
- object_id = models.PositiveIntegerField(default=None)
- content_object = GenericForeignKey('request_ranking_content_type', 'object_id')
- reviewer_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- review_text = models.TextField(default="")
- review_ranking = models.FloatField(default=0.0)
- review_time = models.DateTimeField(auto_now_add=True)
- review_description_images = models.ManyToManyField('Images', blank=True, related_name='review_images')
- ##gen
- # request = GenericForeignKey("request_answer_id")
- class UserMessages(models.Model):
- message_text = models.TextField(default="")
- message_sender_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- time_send = models.DateTimeField(auto_now_add=True)
- topic_type = models.CharField(max_length=25, default="Complain") # ("Complain"),("SELL"),
- # ("RE", "RENT"),("BA", "BARTER"),("CE", "CHAIN_EXCHANGE") ("Two Users Self Messages")
- topic_id = models.ForeignKey(ContentType, on_delete=models.CASCADE)
- description_images = models.ManyToManyField('Images', blank=True, related_name='description_images')
- class Meta:
- ordering = ["topic_type", "topic_id", "time_send"]
- # request = GenericForeignKey("topic_id")
- #gen
- class Complains(models.Model):
- topic_type = models.CharField(max_length=15,
- default="bad content") # "BAD CONTENT","SELL","RENT","EXCHANGE","CHAIN_EXCHANGE"
- topic_content_type = models.ForeignKey(ContentType, on_delete=models.CASCADE, default=None)
- object_id = models.PositiveIntegerField(default=None)
- content_object = GenericForeignKey('topic_content_type', 'object_id')
- complain_description_text = models.TextField(default="")
- images = models.ManyToManyField('Images', blank=True, related_name='complain_description_images')
- initiator_user = models.ForeignKey(Users, related_name='complain_initiator_user', on_delete=models.CASCADE)
- subject_user = models.ForeignKey(Users, related_name="complain_subject_user", on_delete=models.CASCADE)
- created_time = models.DateTimeField(auto_now_add=True)
- resolved = models.BooleanField(default=False)
- class Meta:
- ordering = ["topic_type"]
- class ComplainAnswers(models.Model):
- complain_id = models.ForeignKey(Complains, on_delete=models.CASCADE)
- arbiter_to_resolve = models.ForeignKey(Users, on_delete=models.CASCADE)
- arbiter_verdict = models.TextField(default="")
- sanction = models.CharField(max_length=30, default="no sanctions") # "BLOCK ACCOUNT", "BLOCK SPECIFIED CONTENT",
- # "BLOCK ACCOUNT AND BLOCK SPECIFIED CONTENT", "NO SANCTIONS","BAD COMPLAIN")
- approve_complain = models.BooleanField(default=False)
- sanction_time_available = models.DateTimeField(default=None)
- answer_time = models.DateTimeField(auto_now_add=True)
- # описати платежі
- class Donations(models.Model):
- user_id = models.ForeignKey(Users, on_delete=models.CASCADE)
- donation_time = models.DateTimeField(auto_now_add=True)
- donation_message = models.TextField(default="")
- donation_value = models.FloatField(default=1)
- donation_currency = models.CharField(max_length=3, default="UAH")
- # class SanctionsByAdmins(models.Model): # санкції за неправомірну поведінку адміном
- # зробити узгодження виставлення оцінок
- from django.db import models
- # Create your models here.
- class Document(models.Model):
- docfile = models.FileField(upload_to='documents/%Y/%m/%d')
Add Comment
Please, Sign In to add comment