This commit is contained in:
2024-11-19 13:00:24 +07:00
commit 45e3c1f698
3462 changed files with 617437 additions and 0 deletions

0
home/__init__.py Normal file
View File

21
home/admin.py Normal file
View File

@@ -0,0 +1,21 @@
from django.contrib import admin
from home.models import *
# Sliders Admin Register
admin.site.register(sliderSection)
# Services Admin Register
admin.site.register(serviceSection)
# About Admin Register
admin.site.register(aboutSection)
# Project Category and Section Admin Register
admin.site.register(projectCategory)
admin.site.register(projectSection)
# Clinets Admin Register
admin.site.register(clientSection)
# Home Page SEO Admin Register
admin.site.register(homePageSEO)

6
home/apps.py Normal file
View File

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

103
home/forms.py Normal file
View File

@@ -0,0 +1,103 @@
from django import forms
from home.models import *
# Sliders Form
class sliderForm(forms.ModelForm):
class Meta:
model = sliderSection
fields = '__all__'
widgets = {
'description' : forms.Textarea(attrs={'rows':5}),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
# Services Form
class serviceForm(forms.ModelForm):
class Meta:
model = serviceSection
fields = '__all__'
widgets = {
'slug' : forms.TextInput(attrs={'readonly':'readonly'}),
'fontawesome_icon_class' : forms.TextInput(attrs={'placeholder':'eg. fas fa-laptop-code'}),
'show_call_now_widget' : forms.CheckboxInput(attrs={'type' : 'checkbox'}),
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
# About Section Form
class aboutSectionForm(forms.ModelForm):
class Meta:
model = aboutSection
fields = '__all__'
widgets = {
'long_description' : forms.Textarea(attrs={'rows':4}),
'experience' : forms.TextInput(attrs={'placeholder' : 'eg. Since 2005.'})
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
# Project Section and Project Category Form
class projectCategoryForm(forms.ModelForm):
class Meta:
model = projectCategory
fields = '__all__'
widgets = {
'slug' : forms.TextInput(attrs={'readonly':'readonly'})
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
class projectSectionForm(forms.ModelForm):
class Meta:
model = projectSection
fields = '__all__'
widgets = {
'slug' : forms.TextInput(attrs={'readonly':'readonly'})
}
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
# Client Secton Form
class clientSectionForm(forms.ModelForm):
class Meta:
model = clientSection
fields = '__all__'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'
# ===============> Home Page SEO Form <===============
class homePageSEOForm(forms.ModelForm):
class Meta:
model = homePageSEO
fields = '__all__'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Add Bootstrap classes to form fields
for field in self.fields.values():
field.widget.attrs['class'] = 'form-control'

View File

@@ -0,0 +1,39 @@
# Generated by Django 4.2.4 on 2023-08-31 06:34
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='homePageSEO',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('meta_title', models.CharField(blank=True, max_length=500, null=True)),
('meta_description', models.CharField(blank=True, max_length=1000, null=True)),
],
),
migrations.CreateModel(
name='sliderSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='Home/')),
('title', models.CharField(max_length=200)),
('subtitle', models.CharField(max_length=200)),
('description', models.TextField()),
('button1_text', models.CharField(max_length=100)),
('button1_url', models.CharField(max_length=500)),
('button2_text', models.CharField(max_length=100)),
('button2_url', models.CharField(max_length=500)),
],
options={
'verbose_name_plural': '1. Sliders',
},
),
]

View File

@@ -0,0 +1,27 @@
# Generated by Django 4.2.4 on 2023-08-31 06:43
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='serviceSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200)),
('short_description', models.CharField(max_length=500)),
('fontawesome_icon_class', models.CharField(max_length=100)),
('detail_page_image', models.ImageField(upload_to='Services/')),
('detail_page_description', models.TextField()),
],
options={
'verbose_name_plural': '1. Services',
},
),
]

View File

@@ -0,0 +1,37 @@
# Generated by Django 4.2.4 on 2023-08-31 06:53
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0002_servicesection'),
]
operations = [
migrations.CreateModel(
name='aboutSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('subtitle', models.CharField(max_length=200)),
('title', models.CharField(max_length=200)),
('short_description', models.CharField(max_length=200)),
('long_description', models.TextField()),
('ranking_number', models.IntegerField()),
('tag_line', models.CharField(max_length=200)),
('experience', models.CharField(max_length=200)),
],
options={
'verbose_name_plural': '3. About Section',
},
),
migrations.AlterModelOptions(
name='servicesection',
options={'verbose_name_plural': '2. Service Section'},
),
migrations.AlterModelOptions(
name='slidersection',
options={'verbose_name_plural': '1. Slider Section'},
),
]

View File

@@ -0,0 +1,38 @@
# Generated by Django 4.2.4 on 2023-08-31 07:22
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('home', '0003_aboutsection_alter_servicesection_options_and_more'),
]
operations = [
migrations.CreateModel(
name='projectCategory',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, verbose_name='project_category')),
],
),
migrations.CreateModel(
name='projectSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('image', models.ImageField(upload_to='Projects/')),
('title', models.CharField(max_length=200)),
('description', models.TextField()),
('client', models.CharField(max_length=200)),
('company', models.CharField(max_length=200)),
('duration', models.CharField(max_length=100)),
('category', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='home.projectcategory')),
],
options={
'verbose_name_plural': '5.Project Section',
},
),
]

View File

@@ -0,0 +1,26 @@
# Generated by Django 4.2.4 on 2023-08-31 07:56
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0004_projectcategory_projectsection'),
]
operations = [
migrations.CreateModel(
name='clientSection',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('client_name', models.CharField(max_length=100)),
('image', models.ImageField(upload_to='Clients/')),
],
),
migrations.AlterField(
model_name='projectcategory',
name='name',
field=models.CharField(max_length=200),
),
]

View File

@@ -0,0 +1,17 @@
# Generated by Django 4.2.4 on 2023-08-31 12:36
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0006_clientsection_alter_projectcategory_name'),
]
operations = [
migrations.AlterModelOptions(
name='clientsection',
options={'verbose_name_plural': '6.Client Section'},
),
]

View File

@@ -0,0 +1,30 @@
# Generated by Django 4.2.4 on 2023-08-31 14:28
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0007_alter_clientsection_options'),
]
operations = [
migrations.AddField(
model_name='aboutsection',
name='image',
field=models.ImageField(default='', upload_to='AboutSection/'),
preserve_default=False,
),
migrations.AddField(
model_name='aboutsection',
name='video_thumbnail',
field=models.ImageField(default='', upload_to='AboutSection/'),
preserve_default=False,
),
migrations.AddField(
model_name='aboutsection',
name='video_url',
field=models.CharField(default='', max_length=500),
preserve_default=False,
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 4.2.4 on 2023-09-01 19:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0009_aboutsection_image_aboutsection_video_thumbnail_and_more'),
]
operations = [
migrations.AlterField(
model_name='servicesection',
name='detail_page_description',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='servicesection',
name='detail_page_image',
field=models.ImageField(blank=True, null=True, upload_to='Services/'),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-02 15:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0010_alter_servicesection_detail_page_description_and_more'),
]
operations = [
migrations.AddField(
model_name='projectcategory',
name='slug',
field=models.SlugField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,23 @@
# Generated by Django 4.2.4 on 2023-09-02 16:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0011_projectcategory_slug'),
]
operations = [
migrations.AddField(
model_name='projectsection',
name='slug',
field=models.SlugField(blank=True, null=True),
),
migrations.AddField(
model_name='servicesection',
name='slug',
field=models.SlugField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 4.2.4 on 2023-09-19 15:56
import ckeditor.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0012_projectsection_slug_servicesection_slug'),
]
operations = [
migrations.AlterField(
model_name='servicesection',
name='detail_page_description',
field=ckeditor.fields.RichTextField(blank=True, null=True),
),
]

View File

@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-19 15:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0013_alter_servicesection_detail_page_description'),
]
operations = [
migrations.AddField(
model_name='servicesection',
name='show_call_now_widget',
field=models.BooleanField(default=True),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 4.2.4 on 2023-09-19 17:05
import ckeditor.fields
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('home', '0014_servicesection_show_call_now_widget'),
]
operations = [
migrations.AlterField(
model_name='projectsection',
name='description',
field=ckeditor.fields.RichTextField(),
),
]

View File

@@ -0,0 +1,164 @@
# Generated by Django 4.2.4 on 2023-10-18 05:15
import ckeditor.fields
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('home', '0015_alter_projectsection_description'),
]
operations = [
migrations.AlterField(
model_name='aboutsection',
name='experience',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='image',
field=models.ImageField(blank=True, null=True, upload_to='AboutSection/'),
),
migrations.AlterField(
model_name='aboutsection',
name='long_description',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='ranking_number',
field=models.IntegerField(blank=True, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='short_description',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='subtitle',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='tag_line',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='title',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='aboutsection',
name='video_thumbnail',
field=models.ImageField(blank=True, null=True, upload_to='AboutSection/'),
),
migrations.AlterField(
model_name='aboutsection',
name='video_url',
field=models.CharField(blank=True, max_length=500, null=True),
),
migrations.AlterField(
model_name='clientsection',
name='client_name',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='clientsection',
name='image',
field=models.ImageField(blank=True, null=True, upload_to='Clients/'),
),
migrations.AlterField(
model_name='projectcategory',
name='name',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='projectsection',
name='client',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='projectsection',
name='company',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='projectsection',
name='description',
field=ckeditor.fields.RichTextField(blank=True, null=True),
),
migrations.AlterField(
model_name='projectsection',
name='duration',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='projectsection',
name='image',
field=models.ImageField(blank=True, null=True, upload_to='Projects/'),
),
migrations.AlterField(
model_name='projectsection',
name='title',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='servicesection',
name='fontawesome_icon_class',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='servicesection',
name='name',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='servicesection',
name='short_description',
field=models.CharField(blank=True, max_length=500, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='button1_text',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='button1_url',
field=models.CharField(blank=True, max_length=500, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='button2_text',
field=models.CharField(blank=True, max_length=100, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='button2_url',
field=models.CharField(blank=True, max_length=500, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='description',
field=models.TextField(blank=True, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='image',
field=models.ImageField(blank=True, null=True, upload_to='Home/'),
),
migrations.AlterField(
model_name='slidersection',
name='subtitle',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='slidersection',
name='title',
field=models.CharField(blank=True, max_length=200, null=True),
),
]

View File

@@ -0,0 +1,19 @@
# Generated by Django 4.2.6 on 2023-10-29 09:03
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('home', '0016_alter_aboutsection_experience_and_more'),
]
operations = [
migrations.AlterField(
model_name='projectsection',
name='category',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='home.projectcategory'),
),
]

View File

117
home/models.py Normal file
View File

@@ -0,0 +1,117 @@
from django.db import models
from django.utils.text import slugify
from ckeditor.fields import RichTextField
# Sliders Model
class sliderSection(models.Model):
image = models.ImageField(upload_to='Home/', blank=True, null=True)
title = models.CharField(max_length=200, blank=True, null=True)
subtitle = models.CharField(max_length=200, blank=True, null=True)
description = models.TextField(blank=True, null=True)
button1_text = models.CharField(max_length=100, blank=True, null=True)
button1_url = models.CharField(max_length=500, blank=True, null=True)
button2_text = models.CharField(max_length=100, blank=True, null=True)
button2_url = models.CharField(max_length=500, blank=True, null=True)
def __str__(self):
return self.title
class Meta:
verbose_name_plural = "1. Slider Section"
# Services Model
class serviceSection(models.Model):
name = models.CharField(max_length=200, blank=True, null=True)
slug = models.SlugField(blank=True, null=True)
short_description = models.CharField(max_length=500, blank=True, null=True)
fontawesome_icon_class = models.CharField(max_length=100, blank=True, null=True)
detail_page_image = models.ImageField(upload_to='Services/', blank=True, null=True)
detail_page_description = RichTextField(blank=True, null=True)
show_call_now_widget = models.BooleanField(default=True)
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "2. Service Section"
# About Section Model
class aboutSection(models.Model):
subtitle = models.CharField(max_length=200, blank=True, null=True)
title = models.CharField(max_length=200, blank=True, null=True)
short_description = models.CharField(max_length=200, blank=True, null=True)
long_description = models.TextField(blank=True, null=True)
ranking_number = models.IntegerField(blank=True, null=True)
tag_line = models.CharField(max_length=200, blank=True, null=True)
experience = models.CharField(max_length=200, blank=True, null=True)
image = models.ImageField(upload_to='AboutSection/', blank=True, null=True)
video_thumbnail = models.ImageField(upload_to='AboutSection/', blank=True, null=True)
video_url = models.CharField(max_length=500, blank=True, null=True)
def __str__(self):
return self.title
class Meta:
verbose_name_plural = "3. About Section"
# Project and Project category Section Model
class projectCategory(models.Model):
name = models.CharField(max_length=200, blank=True, null=True)
slug = models.SlugField(blank=True, null=True)
def save(self, *args, **kwargs):
self.slug = slugify(self.name)
super().save(*args, **kwargs)
def __str__(self):
return self.name
class projectSection(models.Model):
image = models.ImageField(upload_to='Projects/', blank=True, null=True)
category = models.ForeignKey(projectCategory, blank=True, null=True, on_delete=models.SET_NULL)
title = models.CharField(max_length=200, blank=True, null=True)
slug = models.SlugField(blank=True, null=True)
description = RichTextField(blank=True, null=True)
client = models.CharField(max_length=200, blank=True, null=True)
company = models.CharField(max_length=200, blank=True, null=True)
duration = models.CharField(max_length=100, blank=True, null=True)
def save(self, *args, **kwargs):
self.slug = slugify(self.title)
super().save(*args, **kwargs)
def getProjectImage(self):
if self.image:
return self.image.url
else:
return 'https://t4.ftcdn.net/jpg/04/73/25/49/360_F_473254957_bxG9yf4ly7OBO5I0O5KABlN930GwaMQz.jpg'
def __str__(self):
return self.title
class Meta:
verbose_name_plural = "5.Project Section"
# Client Section Model
class clientSection(models.Model):
client_name = models.CharField(max_length=100, blank=True, null=True)
image = models.ImageField(upload_to='Clients/', blank=True, null=True)
def __str__(self):
return self.client_name
class Meta:
verbose_name_plural = "6.Client Section"
# Home Page SEO Model
class homePageSEO(models.Model):
meta_title = models.CharField(max_length=500, blank=True, null=True)
meta_description = models.CharField(max_length=1000, blank=True, null=True)
def __str__(self):
return self.meta_title

3
home/tests.py Normal file
View File

@@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

6
home/urls.py Normal file
View File

@@ -0,0 +1,6 @@
from django.urls import path
from home.views import *
urlpatterns = [
path('' , homePageFront, name='homePageFront'),
]

27
home/views.py Normal file
View File

@@ -0,0 +1,27 @@
from django.shortcuts import render
from home.models import *
# ===============> Front Home Page View <===============
def homePageFront(request):
meta = homePageSEO.objects.first()
sliders = sliderSection.objects.all()
services = serviceSection.objects.all()
about = aboutSection.objects.first()
project_categories= projectCategory.objects.all()
projects = projectSection.objects.all().order_by('?')
clients = clientSection.objects.all()
context = {
'meta' : meta,
'sliders' : sliders,
'services' : services,
'about' : about,
'project_categories' : project_categories,
'projects': projects,
'clients' : clients,
}
return render(request, 'front/main/index.html', context)
def error_404(request, exception):
return render(request, 'error/404.html', status=404)