some changes

This commit is contained in:
2025-08-06 13:32:50 +03:30
parent d9d0537ac9
commit 30dcdb2db6
18 changed files with 251 additions and 12 deletions

View File

@@ -14,7 +14,7 @@
</component>
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.10 (bazrasienv)" jdkType="Python SDK" />
<orderEntry type="jdk" jdkName="Python 3.10 (env)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="PyDocumentationSettings">

2
.idea/misc.xml generated
View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (bazrasienv)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (env)" project-jdk-type="Python SDK" />
</project>

View File

@@ -16,7 +16,6 @@ def sync_role_permissions(sender, instance, **kwargs):
permissions = instance.role.permissions.all()
if not instance.permissions.exists():
instance.permissions.add(*permissions) # noqa
print(instance.permissions)
instance._from_signal = True
instance.save()

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-08-06 07:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('herd', '0010_rancher_without_herd'),
]
operations = [
migrations.AddField(
model_name='rancher',
name='herd_code',
field=models.CharField(max_length=100, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2025-08-06 07:35
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('herd', '0011_rancher_herd_code'),
]
operations = [
migrations.AlterField(
model_name='rancher',
name='national_code',
field=models.CharField(max_length=50, null=True),
),
migrations.AlterField(
model_name='rancher',
name='nationality',
field=models.CharField(max_length=50, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2025-08-06 07:49
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('herd', '0012_alter_rancher_national_code_and_more'),
]
operations = [
migrations.AlterField(
model_name='herd',
name='latitude',
field=models.DecimalField(decimal_places=6, max_digits=10, null=True),
),
migrations.AlterField(
model_name='herd',
name='longitude',
field=models.DecimalField(decimal_places=6, max_digits=10, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 5.0 on 2025-08-06 07:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('herd', '0013_alter_herd_latitude_alter_herd_longitude'),
]
operations = [
migrations.AlterField(
model_name='herd',
name='latitude',
field=models.FloatField(default=0),
),
migrations.AlterField(
model_name='herd',
name='longitude',
field=models.FloatField(default=0),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-08-06 07:55
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('herd', '0014_alter_herd_latitude_alter_herd_longitude'),
]
operations = [
migrations.AlterField(
model_name='herd',
name='postal',
field=models.CharField(help_text='herd postal code', max_length=20, null=True),
),
]

View File

@@ -42,7 +42,7 @@ class Herd(BaseModel):
null=True
)
postal = models.CharField(
max_length=10,
max_length=20,
help_text="herd postal code", null=True
)
institution = models.CharField(
@@ -56,8 +56,8 @@ class Herd(BaseModel):
related_name="herd_contractor",
null=True
)
latitude = models.DecimalField(max_digits=22, decimal_places=16, null=True)
longitude = models.DecimalField(max_digits=22, decimal_places=16, null=True)
latitude = models.FloatField(default=0)
longitude = models.FloatField(default=0)
unit_unique_id = models.CharField(max_length=20, null=True)
activity_types = (
("I", "Industrial"),
@@ -82,12 +82,13 @@ class Herd(BaseModel):
class Rancher(BaseModel):
ranching_farm = models.CharField(max_length=150, null=True)
herd_code = models.CharField(max_length=100, null=True)
first_name = models.CharField(max_length=150, null=True)
last_name = models.CharField(max_length=150, null=True)
mobile = models.CharField(max_length=25, null=True)
national_code = models.CharField(max_length=20, null=True)
national_code = models.CharField(max_length=50, null=True)
birthdate = models.DateTimeField(null=True)
nationality = models.CharField(max_length=20, null=True)
nationality = models.CharField(max_length=50, null=True)
address = models.TextField(blank=True)
province = models.ForeignKey(
auth_models.Province,

View File

@@ -0,0 +1,18 @@
# Generated by Django 5.0 on 2025-08-06 08:31
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('livestock', '0012_livestocktype_weight_type'),
]
operations = [
migrations.AddField(
model_name='livestock',
name='archive',
field=models.BooleanField(default=False),
),
]

View File

@@ -88,6 +88,7 @@ class LiveStock(BaseModel):
(2, 'female')
)
gender = models.IntegerField(choices=gender_type, default=1)
archive = models.BooleanField(default=False)
def __str__(self):
return f'{self.type.name}-{self.species.name}'

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 07:25
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0034_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 10, 55, 42, 749910)),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 07:35
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0035_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 11, 5, 16, 207384)),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 07:49
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0036_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 11, 19, 3, 548332)),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 07:51
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0037_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 11, 21, 14, 982190)),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 07:55
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0038_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 11, 25, 53, 734145)),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 5.0 on 2025-08-06 08:31
import datetime
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('pos_device', '0039_alter_deviceactivationcode_expires_at'),
]
operations = [
migrations.AlterField(
model_name='deviceactivationcode',
name='expires_at',
field=models.DateTimeField(default=datetime.datetime(2025, 8, 6, 12, 1, 26, 211551)),
),
]

View File

@@ -52,12 +52,13 @@ class DeviceViewSet(viewsets.ModelViewSet):
def create(self, request, *args, **kwargs):
""" Custom create of pos devices """
company = pos_models.ProviderCompany.objects.get(
user_relation__user=request.user
)
if 'company' not in request.data.keys():
company = pos_models.ProviderCompany.objects.get(
user_relation__user=request.user
)
request.data.update({'company': company.id})
# create device
request.data.update({'company': company.id})
serializer = self.serializer_class(data=request.data)
if serializer.is_valid():
serializer.save()