adding date and comfiguring media and image presenting
This commit is contained in:
18
field/migrations/0003_cost_date.py
Normal file
18
field/migrations/0003_cost_date.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 10:19
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('field', '0002_alter_job_due_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='cost',
|
||||||
|
name='date',
|
||||||
|
field=models.DateTimeField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
field/migrations/0004_rename_due_date_job_date.py
Normal file
18
field/migrations/0004_rename_due_date_job_date.py
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-07 11:23
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('field', '0003_cost_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RenameField(
|
||||||
|
model_name='job',
|
||||||
|
old_name='due_date',
|
||||||
|
new_name='date',
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
# Generated by Django 5.2.4 on 2025-08-08 10:12
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('field', '0004_rename_due_date_job_date'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='job',
|
||||||
|
name='costs',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='job',
|
||||||
|
name='images',
|
||||||
|
),
|
||||||
|
migrations.RemoveField(
|
||||||
|
model_name='job',
|
||||||
|
name='notes',
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='job',
|
||||||
|
name='costs',
|
||||||
|
field=models.ManyToManyField(blank=True, null=True, to='field.cost'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='job',
|
||||||
|
name='images',
|
||||||
|
field=models.ManyToManyField(blank=True, null=True, to='field.image'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='job',
|
||||||
|
name='notes',
|
||||||
|
field=models.ManyToManyField(blank=True, null=True, to='field.note'),
|
||||||
|
),
|
||||||
|
]
|
||||||
@@ -26,6 +26,7 @@ class Cost(models.Model):
|
|||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
user = models.ForeignKey(User, on_delete=models.CASCADE, null=True, blank=True)
|
||||||
name = models.CharField(max_length=255)
|
name = models.CharField(max_length=255)
|
||||||
amount = models.BigIntegerField(default=0)
|
amount = models.BigIntegerField(default=0)
|
||||||
|
date = models.DateTimeField(null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
@@ -71,13 +72,13 @@ class Job(models.Model):
|
|||||||
type = models.CharField(max_length=15, choices=TYPE_CHOICES, default="Irrigating")
|
type = models.CharField(max_length=15, choices=TYPE_CHOICES, default="Irrigating")
|
||||||
field = models.ForeignKey(Field, on_delete=models.CASCADE)
|
field = models.ForeignKey(Field, on_delete=models.CASCADE)
|
||||||
made_date = models.DateTimeField(auto_now_add=True)
|
made_date = models.DateTimeField(auto_now_add=True)
|
||||||
due_date = models.DateField()
|
date = models.DateField()
|
||||||
status = models.BooleanField()
|
status = models.BooleanField()
|
||||||
costs = models.ForeignKey(Cost, on_delete=models.SET_NULL, null=True, blank=True)
|
costs = models.ManyToManyField(Cost, null=True, blank=True)
|
||||||
notes = models.ForeignKey(Note, on_delete=models.SET_NULL, null=True, blank=True)
|
notes = models.ManyToManyField(Note, null=True, blank=True)
|
||||||
##########REMOVE THIS MF!
|
##########REMOVE THIS MF!
|
||||||
# voices = models.ForeignKey(Voice, on_delete=models.SET_NULL, null=True, blank=True)
|
# voices = models.ForeignKey(Voice, on_delete=models.SET_NULL, null=True, blank=True)
|
||||||
images = models.ForeignKey(Image, on_delete=models.SET_NULL, null=True, blank=True)
|
images = models.ManyToManyField(Image, null=True, blank=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.type
|
return self.type
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class CostSerializer(serializers.ModelSerializer):
|
|||||||
|
|
||||||
|
|
||||||
class ImageSerializer(serializers.ModelSerializer):
|
class ImageSerializer(serializers.ModelSerializer):
|
||||||
|
image = serializers.ImageField(use_url=True)
|
||||||
uploaded_at = serializers.SerializerMethodField()
|
uploaded_at = serializers.SerializerMethodField()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@@ -39,15 +40,15 @@ class JobSerializer(serializers.ModelSerializer):
|
|||||||
# costs = serializers.PrimaryKeyRelatedField(
|
# costs = serializers.PrimaryKeyRelatedField(
|
||||||
# queryset=Cost.objects.all(), required=False, allow_null=True
|
# queryset=Cost.objects.all(), required=False, allow_null=True
|
||||||
# )
|
# )
|
||||||
costs = CostSerializer(read_only=True, allow_null=True)
|
costs = CostSerializer(read_only=True, many=True)
|
||||||
# notes = serializers.PrimaryKeyRelatedField(
|
# notes = serializers.PrimaryKeyRelatedField(
|
||||||
# queryset=Note.objects.all(), required=False, allow_null=True
|
# queryset=Note.objects.all(), required=False, many=True
|
||||||
# )
|
# )
|
||||||
notes = NoteSerializer(read_only=True, allow_null=True)
|
notes = NoteSerializer(read_only=True, many=True)
|
||||||
# images = serializers.PrimaryKeyRelatedField(
|
# images = serializers.PrimaryKeyRelatedField(
|
||||||
# queryset=Image.objects.all(), required=False, allow_null=True
|
# queryset=Image.objects.all(), required=False, many=True
|
||||||
# )
|
# )
|
||||||
images = ImageSerializer(read_only=True, allow_null=True)
|
images = ImageSerializer(read_only=True, many=True)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Job
|
model = Job
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ from .views import (
|
|||||||
ProductListCreate,
|
ProductListCreate,
|
||||||
ProductDetail,
|
ProductDetail,
|
||||||
)
|
)
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
|
||||||
|
|
||||||
def register_crud_urls(prefix, list_view, detail_view):
|
def register_crud_urls(prefix, list_view, detail_view):
|
||||||
@@ -32,7 +34,7 @@ urlpatterns += register_crud_urls("images", ImageListCreate, ImageDetail)
|
|||||||
urlpatterns += register_crud_urls("costs", CostListCreate, CostDetail)
|
urlpatterns += register_crud_urls("costs", CostListCreate, CostDetail)
|
||||||
urlpatterns += register_crud_urls("fields", FieldListCreate, FieldDetail)
|
urlpatterns += register_crud_urls("fields", FieldListCreate, FieldDetail)
|
||||||
urlpatterns += register_crud_urls("products", ProductListCreate, ProductDetail)
|
urlpatterns += register_crud_urls("products", ProductListCreate, ProductDetail)
|
||||||
|
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
# urlpatterns = [
|
# urlpatterns = [
|
||||||
# path("jobs/", JobListCreate.as_view(), name="job-createlist"),
|
# path("jobs/", JobListCreate.as_view(), name="job-createlist"),
|
||||||
|
|||||||
BIN
images/بستن_حسابها.png
Normal file
BIN
images/بستن_حسابها.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 244 KiB |
BIN
images/رسیدگی_مالیاتی.png
Normal file
BIN
images/رسیدگی_مالیاتی.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 237 KiB |
BIN
media/images/مالیات_سرمایه_گذاری.png
Normal file
BIN
media/images/مالیات_سرمایه_گذاری.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 238 KiB |
BIN
media/images/مالیات_پزشکان.png
Normal file
BIN
media/images/مالیات_پزشکان.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 242 KiB |
@@ -143,6 +143,8 @@ USE_I18N = True
|
|||||||
|
|
||||||
USE_TZ = True
|
USE_TZ = True
|
||||||
|
|
||||||
|
MEDIA_URL = "/media/"
|
||||||
|
MEDIA_ROOT = BASE_DIR / "media"
|
||||||
|
|
||||||
# Static files (CSS, JavaScript, Images)
|
# Static files (CSS, JavaScript, Images)
|
||||||
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
# https://docs.djangoproject.com/en/5.2/howto/static-files/
|
||||||
|
|||||||
Reference in New Issue
Block a user