Skip to content

Commit 1730b8a

Browse files
committed
WeatherApp
0 parents  commit 1730b8a

24 files changed

+394
-0
lines changed

.idea/.gitignore

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/WeatherApp.iml

+30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/inspectionProfiles/profiles_settings.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WeatherApp/__init__.py

Whitespace-only changes.

WeatherApp/asgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
ASGI config for WeatherApp project.
3+
4+
It exposes the ASGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/howto/deployment/asgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.asgi import get_asgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WeatherApp.settings')
15+
16+
application = get_asgi_application()

WeatherApp/settings.py

+125
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
"""
2+
Django settings for WeatherApp project.
3+
4+
Generated by 'django-admin startproject' using Django 4.2.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/topics/settings/
8+
9+
For the full list of settings and their values, see
10+
https://docs.djangoproject.com/en/4.2/ref/settings/
11+
"""
12+
13+
from pathlib import Path
14+
15+
# Build paths inside the project like this: BASE_DIR / 'subdir'.
16+
BASE_DIR = Path(__file__).resolve().parent.parent
17+
18+
19+
# Quick-start development settings - unsuitable for production
20+
# See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/
21+
22+
# SECURITY WARNING: keep the secret key used in production secret!
23+
SECRET_KEY = 'django-insecure-d=vpyla%a)gr%lnd+*&z$zk+266%w632j5$j=6mb#i-*mrxr@*'
24+
25+
# SECURITY WARNING: don't run with debug turned on in production!
26+
DEBUG = True
27+
28+
ALLOWED_HOSTS = []
29+
30+
31+
# Application definition
32+
33+
INSTALLED_APPS = [
34+
'django.contrib.admin',
35+
'django.contrib.auth',
36+
'django.contrib.contenttypes',
37+
'django.contrib.sessions',
38+
'django.contrib.messages',
39+
'django.contrib.staticfiles',
40+
'weather',
41+
]
42+
43+
MIDDLEWARE = [
44+
'django.middleware.security.SecurityMiddleware',
45+
'django.contrib.sessions.middleware.SessionMiddleware',
46+
'django.middleware.common.CommonMiddleware',
47+
'django.middleware.csrf.CsrfViewMiddleware',
48+
'django.contrib.auth.middleware.AuthenticationMiddleware',
49+
'django.contrib.messages.middleware.MessageMiddleware',
50+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
51+
]
52+
53+
ROOT_URLCONF = 'WeatherApp.urls'
54+
55+
TEMPLATES = [
56+
{
57+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
58+
'DIRS': [BASE_DIR / 'templates']
59+
,
60+
'APP_DIRS': True,
61+
'OPTIONS': {
62+
'context_processors': [
63+
'django.template.context_processors.debug',
64+
'django.template.context_processors.request',
65+
'django.contrib.auth.context_processors.auth',
66+
'django.contrib.messages.context_processors.messages',
67+
],
68+
},
69+
},
70+
]
71+
72+
WSGI_APPLICATION = 'WeatherApp.wsgi.application'
73+
74+
75+
# Database
76+
# https://docs.djangoproject.com/en/4.2/ref/settings/#databases
77+
78+
DATABASES = {
79+
'default': {
80+
'ENGINE': 'django.db.backends.sqlite3',
81+
'NAME': BASE_DIR / 'db.sqlite3',
82+
}
83+
}
84+
85+
86+
# Password validation
87+
# https://docs.djangoproject.com/en/4.2/ref/settings/#auth-password-validators
88+
89+
AUTH_PASSWORD_VALIDATORS = [
90+
{
91+
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
92+
},
93+
{
94+
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
95+
},
96+
{
97+
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
98+
},
99+
{
100+
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
101+
},
102+
]
103+
104+
105+
# Internationalization
106+
# https://docs.djangoproject.com/en/4.2/topics/i18n/
107+
108+
LANGUAGE_CODE = 'en-us'
109+
110+
TIME_ZONE = 'UTC'
111+
112+
USE_I18N = True
113+
114+
USE_TZ = True
115+
116+
117+
# Static files (CSS, JavaScript, Images)
118+
# https://docs.djangoproject.com/en/4.2/howto/static-files/
119+
120+
STATIC_URL = 'static/'
121+
122+
# Default primary key field type
123+
# https://docs.djangoproject.com/en/4.2/ref/settings/#default-auto-field
124+
125+
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

WeatherApp/urls.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.contrib import admin
2+
from django.urls import path, include
3+
4+
urlpatterns = [
5+
path('admin/', admin.site.urls),
6+
path('', include('weather.urls')),
7+
]

WeatherApp/wsgi.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""
2+
WSGI config for WeatherApp project.
3+
4+
It exposes the WSGI callable as a module-level variable named ``application``.
5+
6+
For more information on this file, see
7+
https://docs.djangoproject.com/en/4.2/howto/deployment/wsgi/
8+
"""
9+
10+
import os
11+
12+
from django.core.wsgi import get_wsgi_application
13+
14+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WeatherApp.settings')
15+
16+
application = get_wsgi_application()

db.sqlite3

132 KB
Binary file not shown.

manage.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env python
2+
"""Django's command-line utility for administrative tasks."""
3+
import os
4+
import sys
5+
6+
7+
def main():
8+
"""Run administrative tasks."""
9+
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'WeatherApp.settings')
10+
try:
11+
from django.core.management import execute_from_command_line
12+
except ImportError as exc:
13+
raise ImportError(
14+
"Couldn't import Django. Are you sure it's installed and "
15+
"available on your PYTHONPATH environment variable? Did you "
16+
"forget to activate a virtual environment?"
17+
) from exc
18+
execute_from_command_line(sys.argv)
19+
20+
21+
if __name__ == '__main__':
22+
main()

templates/weather/index.html

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<!DOCTYPE html>
2+
<html lang="uk">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device=width, initial=scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Погодний додаток</title>
8+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
9+
</head>
10+
<body>
11+
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-mb-4 mb-3 bg-white border-bottom shadow-sm">
12+
<h5 class="my-0 mr-md-auto font-weight-normal">itProger</h5>
13+
<nav class="d-inline-flex mt-2 mt-md-0 ms-md-auto">
14+
<a class="me-3 py-2 link-body-emphasis text-decoration-none" href="#">Головна сторінка</a>
15+
<a class="me-3 py-2 link-body-emphasis text-decoration-none" href="#">Інформація</a>
16+
</nav>
17+
<a class="btn btn-outline-primary" href="#">Документація</a>
18+
</div>
19+
<div class="container mt-5">
20+
<div class="row">
21+
<div class="col-5 offset-2">
22+
<h1>Погода у вашому місті</h1>
23+
<form action="" method="post">
24+
{% csrf_token %}
25+
<label for="city">Місто</label>
26+
{{ form.name }}
27+
<input type="submit" name="send" value="Дізнатися" class="mt-2 btn btn-danger">
28+
</form>
29+
</div>
30+
<div class="col-4 offset-1">
31+
<h1>Інформація</h1>
32+
33+
{% for info in all_info %}
34+
<div class="alert alert-info">
35+
<div class="row">
36+
<div class="col-9">
37+
<b>Місто:</b> {{ info.city }}<br>
38+
<b>Температура:</b> {{ info.temp }}<sup>o</sup><br>
39+
</div>
40+
<div class="col-2 offset-1">
41+
<img src="http://openweathermap.org/img/w/{{ info.icon }}.png" alt="Фото погоди">
42+
</div>
43+
</div>
44+
</div>
45+
{% endfor %}
46+
47+
</div>
48+
</div>
49+
</div>
50+
51+
</body>
52+
</html>
53+
54+

weather/__init__.py

Whitespace-only changes.

weather/admin.py

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from django.contrib import admin
2+
from .models import City
3+
4+
admin.site.register(City)

weather/apps.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.apps import AppConfig
2+
3+
4+
class WeatherConfig(AppConfig):
5+
default_auto_field = 'django.db.models.BigAutoField'
6+
name = 'weather'

weather/forms.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from .models import City
2+
from django.forms import ModelForm, TextInput
3+
4+
class CityForm(ModelForm):
5+
class Meta:
6+
model = City
7+
fields = ['name']
8+
widgets = {'name': TextInput(attrs={
9+
'class': 'form-control',
10+
'name': 'city',
11+
'id': 'city',
12+
'placeholder': 'Введіть місто'
13+
})}

weather/migrations/0001_initial.py

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Generated by Django 4.2 on 2023-05-02 11:22
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
initial = True
9+
10+
dependencies = [
11+
]
12+
13+
operations = [
14+
migrations.CreateModel(
15+
name='City',
16+
fields=[
17+
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
18+
('name', models.CharField(max_length=30)),
19+
],
20+
),
21+
]

weather/migrations/__init__.py

Whitespace-only changes.

weather/models.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from django.db import models
2+
3+
class City(models.Model):
4+
name = models.CharField(max_length=30)
5+
6+
def __srt__(self):
7+
return self.name

weather/tests.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.test import TestCase
2+
3+
# Create your tests here.

weather/urls.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from django.urls import path
2+
from . import views
3+
4+
urlpatterns = [
5+
path('', views.index),
6+
]

0 commit comments

Comments
 (0)