Skip to content

Commit

Permalink
professional
Browse files Browse the repository at this point in the history
  • Loading branch information
ravshanbekio committed Jan 20, 2022
0 parents commit 37fdda8
Show file tree
Hide file tree
Showing 1,092 changed files with 408,951 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.env
__pycache__/
db.sqlite3
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn Yuksalish.wsgi --log-file -
Empty file added Yuksalish/__init__.py
Empty file.
16 changes: 16 additions & 0 deletions Yuksalish/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for Yuksalish project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Yuksalish.settings')

application = get_asgi_application()
144 changes: 144 additions & 0 deletions Yuksalish/settings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
"""
Django settings for Yuksalish project.
Generated by 'django-admin startproject' using Django 3.2.9.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.2/ref/settings/
"""

from pathlib import Path
from environs import Env
import cloudinary
import cloudinary.uploader
import cloudinary.api

#Environment variables
env = Env()
env.read_env()
# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path(__file__).resolve().parent.parent


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env.str("SECRET_KEY")

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = env.bool("DEBUG", default=False)

ALLOWED_HOSTS = ['.herokuapp.com','127.0.0.1']


# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'crispy_forms',
'YuksalishApp.apps.YuksalishappConfig',
'cloudinary',
]

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'Yuksalish.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR.joinpath('templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]

WSGI_APPLICATION = 'Yuksalish.wsgi.application'


# Database
# https://docs.djangoproject.com/en/3.2/ref/settings/#databases

DATABASES = {
'default': env.dj_db_url("DATABASE_URL")
}


# Password validation
# https://docs.djangoproject.com/en/3.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]


# Internationalization
# https://docs.djangoproject.com/en/3.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'Asia/Tashkent'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.2/howto/static-files/

STATIC_URL = '/static/'
STATICFILES_DIRS = [BASE_DIR.joinpath('static')]
STATIC_ROOT= BASE_DIR.joinpath('staticfiles')
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

cloudinary.config(
cloud_name = "uzravshanenergy",
api_key = "456822187743137",
api_secret = "_QRnYx2_zfQwudiFpWAeruNP1QE"
)

# Default primary key field type
# https://docs.djangoproject.com/en/3.2/ref/settings/#default-auto-field

DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

CRISPY_TEMPLATE_PACK = 'bootstrap4'
27 changes: 27 additions & 0 deletions Yuksalish/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Yuksalish URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
path('admin/', admin.site.urls),
path('',include('YuksalishApp.urls'))
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,
document_root=settings.MEDIA_ROOT)
16 changes: 16 additions & 0 deletions Yuksalish/wsgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
WSGI config for Yuksalish project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Yuksalish.settings')

application = get_wsgi_application()
Empty file added YuksalishApp/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions YuksalishApp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from django.contrib import admin
from .models import News, Events, Location, Contact, City

@admin.register(News)
class NewsAdmin(admin.ModelAdmin):
fields = ('title','date','text','author','image')
list_display = ('title','date','author')
list_filter = ('title','date','author')
search_fields = ['title','author','date','text']

@admin.register(Events)
class EventsAdmin(admin.ModelAdmin):
fields = ('viloyat','city','address','phone','image','url')
list_display = ('viloyat','city','phone','url')
search_fields = ['viloyat','city','phone']

admin.site.register(Location)
@admin.register(Contact)
class ContactAdmin(admin.ModelAdmin):
fields = ('name','address','city','phone','image')
list_display = ('name','address','city','phone')
search_fields = ['name','address','city','phone']
admin.site.register(City)

6 changes: 6 additions & 0 deletions YuksalishApp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class YuksalishappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'YuksalishApp'
22 changes: 22 additions & 0 deletions YuksalishApp/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django import forms
from django.forms import ModelForm
from .models import Contact

class ContactForm(ModelForm):
class Meta:
model = Contact
fields = ('name','address','city','phone','image')
labels = {
'name': 'F.I.O',
'address': 'Manzil',
'city': 'Shahar/tuman',
'phone': 'Telefon raqam',
'image': "Tug'ilganlik haqida guvohnoma yoki passport",
}
widgets = {
'name': forms.TextInput(attrs={'type':'text', 'class':'form-control', 'id':'name', 'name':'name'}),
'address': forms.Select(attrs={'class':'form-control', 'name':'location', 'id':'filial'}),
'city': forms.Select(attrs={'class':'form-control', 'name':'location2', 'id':'shahar'}),
'phone': forms.TextInput(attrs={'type':'phone', 'class':'form-control', 'id':'phone', 'name':'phone'}),
'image': forms.FileInput(attrs={'type':'file', 'name':'image', 'id':'image'})
}
27 changes: 27 additions & 0 deletions YuksalishApp/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Generated by Django 3.2.9 on 2021-12-27 10:50

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),
]

operations = [
migrations.CreateModel(
name='News',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=150, verbose_name='Sarlavha')),
('date', models.DateField(verbose_name='Sana')),
('text', models.TextField(verbose_name='Matn')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
16 changes: 16 additions & 0 deletions YuksalishApp/migrations/0002_delete_news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.9 on 2021-12-27 11:00

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('YuksalishApp', '0001_initial'),
]

operations = [
migrations.DeleteModel(
name='News',
),
]
29 changes: 29 additions & 0 deletions YuksalishApp/migrations/0003_news.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 3.2.9 on 2021-12-27 11:00

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),
('YuksalishApp', '0002_delete_news'),
]

operations = [
migrations.CreateModel(
name='News',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=150, verbose_name='Sarlavha')),
('date', models.DateField(verbose_name='Sana')),
('text', models.TextField(verbose_name='Matn')),
('image', models.ImageField(upload_to='img')),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
23 changes: 23 additions & 0 deletions YuksalishApp/migrations/0004_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 3.2.9 on 2021-12-27 15:44

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('YuksalishApp', '0003_news'),
]

operations = [
migrations.CreateModel(
name='Events',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('viloyat', models.CharField(max_length=150)),
('city', models.CharField(max_length=200, verbose_name='Shahar/tuman')),
('address', models.CharField(max_length=150, verbose_name='Manzil')),
('phone', models.CharField(max_length=15, verbose_name='Telefon raqam')),
],
),
]
16 changes: 16 additions & 0 deletions YuksalishApp/migrations/0005_delete_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Django 3.2.9 on 2021-12-27 15:46

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('YuksalishApp', '0004_events'),
]

operations = [
migrations.DeleteModel(
name='Events',
),
]
Loading

0 comments on commit 37fdda8

Please sign in to comment.