Ejemplo n.º 1
0
class Listing(QuicksellModel):
	"""Listing model."""

	class Status(IntegerChoices):
		"""Listing's poissble states."""

		draft = 0, 'Draft'
		active = 1, 'Active'
		sold = 2, 'Sold'
		closed = 3, 'Closed'
		deleted = 4, 'Deleted'

	uuid = UUIDField(default=uuid.uuid4, unique=True, editable=False)
	title = CharField(max_length=200)
	description = TextField(null=True, blank=True)
	price = PositiveIntegerField()
	category = ForeignKey('Category', on_delete=SET(uncategorized))
	status = PositiveSmallIntegerField(choices=Status.choices, default=0)
	quantity = PositiveIntegerField(default=1)
	sold = PositiveIntegerField(default=0)
	views = PositiveIntegerField(default=0)
	date_created = DateTimeField(default=datetime.now, editable=False)
	date_expires = DateTimeField(default=default_expiration_date)
	condition_new = BooleanField(default=False)
	properties = JSONField(null=True, blank=True)
	seller = ForeignKey('Profile', related_name='listings', on_delete=CASCADE)
	location = ForeignKey(**location_fk_kwargs)

	def __str__(self):
		return self.title
Ejemplo n.º 2
0
class Fan(Versionable):
    name = CharField(max_length=200)
    team = VersionedForeignKey(Team, null=False, on_delete=SET(default_team))

    __str__ = versionable_description
Ejemplo n.º 3
0
 def __init__(self, **kwargs):
     kwargs['limit_choices_to'] = {'is_staff': False}
     # Override on_delete, even if it was already defined in kwargs
     kwargs['on_delete'] = SET(_transfer_assignation)
     kwargs.setdefault('to', settings.AUTH_USER_MODEL)
     super().__init__(**kwargs)