create initial models and mobile test for mojtaba eshaghi

This commit is contained in:
2025-05-05 15:25:46 +03:30
parent 7e301c14b7
commit ec58d9ef5e
167 changed files with 614 additions and 23 deletions

0
apps/tag/__init__.py Normal file
View File

3
apps/tag/admin.py Normal file
View File

@@ -0,0 +1,3 @@
from django.contrib import admin
# Register your models here.

6
apps/tag/apps.py Normal file
View File

@@ -0,0 +1,6 @@
from django.apps import AppConfig
class TagConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'apps.tag'

View File

View File

View File

@@ -0,0 +1 @@
# Your custom management commands go here.

View File

@@ -0,0 +1,36 @@
# Generated by Django 4.2.20 on 2025-05-05 11:54
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('authentication', '0007_user_ownership'),
]
operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('create_date', models.DateTimeField(auto_now_add=True)),
('modify_date', models.DateTimeField(auto_now=True)),
('trash', models.BooleanField(default=False)),
('code', models.CharField(max_length=20)),
('status', models.CharField(max_length=20, null=True)),
('created_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_createdby', to=settings.AUTH_USER_MODEL)),
('modified_by', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='%(class)s_modifiedby', to=settings.AUTH_USER_MODEL)),
('organization', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tag_organization', to='authentication.organization')),
('province', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, related_name='tag_province', to='authentication.province')),
],
options={
'abstract': False,
},
),
]

View File

View File

View File

View File

View File

View File

30
apps/tag/models.py Normal file
View File

@@ -0,0 +1,30 @@
from apps.livestock import models as livestock_models
from apps.authentication import models as auth_models
from apps.authorization import models as authoriz_models
from apps.core.models import BaseModel
from django.db import models
class Tag(BaseModel):
code = models.CharField(max_length=20)
province = models.ForeignKey(
auth_models.Province,
on_delete=models.CASCADE,
related_name="tag_province",
null=True
)
organization = models.ForeignKey(
auth_models.Organization,
on_delete=models.CASCADE,
related_name='tag_organization',
null=True
)
status = models.CharField(max_length=20, null=True)
def __str__(self):
return f'{self.code}'
def save(self, *args, **kwargs):
super(Tag, self).save(*args, **kwargs)

25
apps/tag/permissions.py Normal file
View File

@@ -0,0 +1,25 @@
from rest_framework import permissions
# example Code
class AuthorAllStaffAllButEditOrReadOnly(permissions.BasePermission):
edit_methods = ("PUT", "PATCH")
def has_permission(self, request, view):
if request.user.is_authenticated:
return True
def has_object_permission(self, request, view, obj):
if request.user.is_superuser:
return True
if request.method in permissions.SAFE_METHODS:
return True
if obj.author == request.user:
return True
if request.user.is_staff and request.method not in self.edit_methods:
return True
return False

View File

View File

View File

View File

View File

1
apps/tag/services.py Normal file
View File

@@ -0,0 +1 @@
# Your services go here

1
apps/tag/urls.py Normal file
View File

@@ -0,0 +1 @@
# Your urls go here

View File

View File

View File

View File

View File