mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Create new model for "PartCategory"
This commit is contained in:
parent
4cf6b9bd31
commit
cf023e2cc1
27
InvenTree/part/migrations/0074_partcategorystar.py
Normal file
27
InvenTree/part/migrations/0074_partcategorystar.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# Generated by Django 3.2.5 on 2021-11-03 07:03
|
||||||
|
|
||||||
|
from django.conf import settings
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
||||||
|
('part', '0073_auto_20211013_1048'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='PartCategoryStar',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('category', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_users', to='part.partcategory', verbose_name='Category')),
|
||||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='starred_categories', to=settings.AUTH_USER_MODEL, verbose_name='User')),
|
||||||
|
],
|
||||||
|
options={
|
||||||
|
'unique_together': {('category', 'user')},
|
||||||
|
},
|
||||||
|
),
|
||||||
|
]
|
@ -2062,10 +2062,9 @@ class PartInternalPriceBreak(common.models.PriceBreak):
|
|||||||
|
|
||||||
|
|
||||||
class PartStar(models.Model):
|
class PartStar(models.Model):
|
||||||
""" A PartStar object creates a relationship between a User and a Part.
|
""" A PartStar object creates a subscription relationship between a User and a Part.
|
||||||
|
|
||||||
It is used to designate a Part as 'starred' (or favourited) for a given User,
|
It is used to designate a Part as 'subscribed' for a given User.
|
||||||
so that the user can track a list of their favourite parts.
|
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
part: Link to a Part object
|
part: Link to a Part object
|
||||||
@ -2077,7 +2076,30 @@ class PartStar(models.Model):
|
|||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('User'), related_name='starred_parts')
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('User'), related_name='starred_parts')
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
unique_together = ['part', 'user']
|
unique_together = [
|
||||||
|
'part',
|
||||||
|
'user'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
class PartCategoryStar(models.Model):
|
||||||
|
"""
|
||||||
|
A PartCategoryStar creates a subscription relationship between a User and a PartCategory.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
category: Link to a PartCategory object
|
||||||
|
user: Link to a User object
|
||||||
|
"""
|
||||||
|
|
||||||
|
category = models.ForeignKey(PartCategory, on_delete=models.CASCADE, verbose_name=_('Category'), related_name='starred_users')
|
||||||
|
|
||||||
|
user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name=_('User'), related_name='starred_categories')
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
unique_together = [
|
||||||
|
'category',
|
||||||
|
'user',
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class PartTestTemplate(models.Model):
|
class PartTestTemplate(models.Model):
|
||||||
|
Loading…
Reference in New Issue
Block a user