Skip to content

Commit fb4facd

Browse files
committed
fin
1 parent e0920d6 commit fb4facd

File tree

11 files changed

+95
-77
lines changed

11 files changed

+95
-77
lines changed

.idea/misc.xml

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

.idea/pythonProject5.iml

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

site_cards/cards/models.py

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ class Shine(models.Model):
1414
def __str__(self):
1515
return self.short_note
1616

17+
class Times(models.Model):
18+
time1 = models.TextField(blank=True)
19+
1720

1821

1922

site_cards/cards/templates/cards/action.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<h2>Действия с записью</h2>
99
{% if a %}
1010

11-
<h3>{{ a.short_note }} | {{ a.price }} | {{ a.company }}</h3>
11+
<h3>{{ a.short_note }} | {{ a.price }} руб| {{ a.company }}</h3>
1212
<h3><a href="{{ a.href }}">{{ a.href }}</a> </h3>
1313

1414

site_cards/cards/templates/cards/base.html

+9-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
<head>
44
<meta charset="UTF-8">
55

6-
<h3>
7-
<a href="{% url 'main page' %}" type="submit">Главная страница</a>-----
8-
<a href="{% url 'search' %}" type="submit">Поиск шин</a>-----
9-
<a href="{% url 'report' %}" type="submit">Отчеты</a>---------
10-
<a href="{% url 'ubdate' %}" type="submit">Обновить базу</a> (примерно 15 сек)
11-
</h3>
6+
<h1>
7+
<ul class="nav nav-pills">
8+
<li class="nav-item"><a href="{% url 'main page' %}" class="nav-link active" aria-current="page">Главная</a></li>-
9+
<li class="nav-item"><a href="{% url 'search' %}" class="nav-link active" aria-current="page">Поиск шин</a></li>-
10+
<li class="nav-item"><a href="{% url 'ubdate' %}" class="nav-link active" aria-current="page">Обновить базу(20 сек)</a></li>
11+
12+
</ul>
13+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css">
14+
</h1>
1215
<title>{% block title %}
1316
{% endblock %}</title>
1417
</head>

site_cards/cards/templates/cards/index.html

+10-8
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,24 @@
66

77
{% block content %}
88

9-
<h1>Склад-магазин б/у шин. г. Минск ул. Бабушкина 17/5</h1>
10-
<p>Здесь можно посмотреть наличие и цену интересующих вас шин. Обновление каждый день.
11-
При покупке шин, на шиномонтаж скидка 30%</p>
12-
<h2>
13-
<a href="{% url 'report' %}" type="submit">Отчеты</a>
9+
<h1>Склад-магазин б/у шин. г. Минск.</h1>
10+
<H3>Здесь можно посмотреть наличие и цену интересующих вас шин. Обновление каждый день.
11+
При покупке шин, на шиномонтаж скидка 30%</H3>
1412

15-
</h2>
1613
<h2>
1714

1815
<a href="{% url 'search' %}" type="submit">Найти шины</a>
1916
</h2>
2017
{% if a %}
21-
<h3>{{ a }}</h3>
18+
<h3>Текущее время: {{ a }}</h3>
2219
{% endif %}
20+
{% if tims %}
21+
{% for i in tims %}
22+
<h3>Время последнего обновления: {{ i.time1 }}</h3>
23+
{% endfor %}
24+
{% endif %}
25+
2326
<img src="/media/1046506409.jpg" height="150px">
24-
<img src="/media/4719539720.jpg" height="150px">
2527
<img src="/media/5588884675.jpg" height="150px">
2628
<img src="/media/5027452130.jpg" height="150px">
2729
<img src="/media/5569102827.jpg" height="150px">

site_cards/cards/templates/cards/search.html

+19-11
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,29 @@
77
{% block content %}
88

99
<h1>Поиск шин</h1>
10+
{% if tims %}
11+
{% for i in tims %}
12+
<h1>Последнее обновление: {{ i.time1 }}</h1>
13+
{% endfor %}
14+
{% endif %}
1015

11-
<form method="post" enctype="multipart/form-data">
16+
<h1>
17+
<form class="d-flex" method="post" enctype="multipart/form-data">
1218
{% csrf_token %}
1319

14-
<h4>
15-
<input type="text" placeholder="описание" name="radius">
16-
<input type="text" placeholder="ширина" name="shirina">
17-
<input type="text" placeholder="высота" name="visota">
18-
<input type="text" placeholder="диаметр" name="diametr">
19-
<input type="text" placeholder="продавец" name="saler">
2020

21-
<button type="submit">Поиск</button>
22-
</h4>
21+
<ul class="nav nav-pills">
22+
<li class="nav-item"><input type="text" placeholder="описание" name="radius"></li>
23+
<li class="nav-item"><input type="text" placeholder="ширина" name="shirina"></li>
24+
<li class="nav-item"><input type="text" placeholder="высота" name="visota"></li>
25+
<li class="nav-item"><input type="text" placeholder="диаметр" name="diametr"></li>
26+
<li class="nav-item"><input type="text" placeholder="продавец" name="saler"></li>
27+
</ul>
28+
29+
<button class="btn btn-outline-success" type="submit">Поиск</button>
2330

2431
</form>
32+
</h1>
2533
{% if b_1 %}
2634
<h2>{{ b_1 }} Всего объявлений: {{ r_count }} Время обновления {{ time }}</h2>
2735

@@ -30,11 +38,11 @@ <h2>{{ b_1 }} Всего объявлений: {{ r_count }} Время обно
3038
{% if a %}
3139
{% for i in a %}
3240
<div>
33-
<h4><a href="{% url 'action' pk=i.pk %}">
41+
<h3><a href="{% url 'action' pk=i.pk %}">
3442
{{ i.number }} | {{ i.short_note }} | {{ i.price }} руб | {{ i.shirina }}
3543
/ {{ i.visota }} {{ i.diametr }} | {{ i.company }}
3644

37-
</a></h4>
45+
</a></h3>
3846

3947

4048
</div>

site_cards/cards/urls.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
from django.contrib import admin
22
from django.urls import path
33

4-
from cards.views import main_page, report, search, del_card, ubdate
4+
from cards.views import main_page, search, del_card, ubdate
55

66
urlpatterns = [
77
path('', main_page, name="main page"),
8-
path('report/', report, name="report"),
98
path('search/', search, name="search"),
109
path('action/<int:pk>', del_card, name="action"),
1110
path('ubdate', ubdate, name="ubdate")

site_cards/cards/views.py

+50-47
Original file line numberDiff line numberDiff line change
@@ -7,56 +7,55 @@
77
from django.shortcuts import render, redirect
88

99
from cards.forms import ShineForm
10-
from cards.models import Shine
10+
from cards.models import Shine, Times
1111

1212

1313

1414
def main_page(request):
1515
now = datetime.now()
16-
a = now.strftime("%H:%M:%S")
17-
# if a > "16:00:00":
18-
# ubdate(request)
19-
20-
return render(request, 'cards/index.html', {"a": a})
21-
22-
def report(request):
23-
if request.method == "GET":
24-
return render(request, 'cards/report.html')
25-
26-
if request.method == "POST":
27-
saler = request.POST["saler"]
28-
if saler:
29-
if saler == "все":
30-
a = Shine.objects.all()
31-
else:
32-
a = Shine.objects.filter(
33-
Q(company__iregex=saler) | Q(company__iregex=saler))
34-
b, byn_2, count = "", 0, 0
35-
count_B17 = 0
36-
for i in a:
37-
count += 1
38-
if int(i.number) == 1: b = str(i.company)
39-
elif "Б17" in i.short_note:
40-
count_B17 += 1
41-
42-
43-
byn = i.price
44-
byn_1 = ""
45-
for el in str(byn):
46-
if el.isdigit():
47-
byn_1 = byn_1 + el
48-
elif el == "р": break
49-
if byn_1 == "": by = 0
50-
else: by = int(byn_1)
51-
byn_2 = byn_2 + by
52-
if saler == "все": b = "всех продавцов"
53-
54-
return render(request, 'cards/report.html',
55-
{"b": b, "byn_2": byn_2, "count": count, "count_B17": count_B17})
16+
a = now.strftime('%d-%m-%Y %H:%M')
17+
tims = Times.objects.all()
18+
19+
return render(request, 'cards/index.html', {"a": a, "tims": tims})
20+
21+
# def report(request):
22+
# if request.method == "GET":
23+
# return render(request, 'cards/report.html')
24+
#
25+
# if request.method == "POST":
26+
# saler = request.POST["saler"]
27+
# if saler:
28+
# if saler == "все":
29+
# a = Shine.objects.all()
30+
# else:
31+
# a = Shine.objects.filter(
32+
# Q(company__iregex=saler) | Q(company__iregex=saler))
33+
# b, byn_2, count = "", 0, 0
34+
# count_B17 = 0
35+
# for i in a:
36+
# count += 1
37+
# if int(i.number) == 1: b = str(i.company)
38+
# elif "Б17" in i.short_note:
39+
# count_B17 += 1
40+
#
41+
# byn = i.price
42+
# byn_1 = ""
43+
# for el in str(byn):
44+
# if el.isdigit():
45+
# byn_1 = byn_1 + el
46+
# elif el == "р": break
47+
# if byn_1 == "": by = 0
48+
# else: by = int(byn_1)
49+
# byn_2 = byn_2 + by
50+
# if saler == "все": b = "всех продавцов"
51+
#
52+
# return render(request, 'cards/report.html',
53+
# {"b": b, "byn_2": byn_2, "count": count, "count_B17": count_B17})
5654

5755
def search(request):
56+
tims = Times.objects.all()
5857
if request.method == "GET":
59-
return render(request, 'cards/search.html')
58+
return render(request, 'cards/search.html', {"tims": tims})
6059

6160
if request.method == "POST":
6261
radius = request.POST["radius"]
@@ -99,7 +98,6 @@ def ubdate(request):
9998
if request.method == "GET":
10099
a = Shine.objects.all()
101100
a.delete()#очистка бд
102-
#shutil.rmtree('media/media/site_cards')#удаление фоток
103101

104102
l_3 = []
105103
company = ["3186887", "3558328", "5409979", "887851"]
@@ -159,16 +157,21 @@ def pars_company(xx):
159157

160158
r_count = 0
161159
for yy in l_3:
162-
163160
for xx in yy:
164-
if yy == l_3[-1]:
165-
xx[8] = "ЦентрТрансСнаб_2"
161+
if yy == l_3[-1]: xx[8] = "Сергей"
162+
elif yy == l_3[0]: xx[8] = "Максим"
163+
elif yy == l_3[1]: xx[8] = "Никита"
164+
elif yy == l_3[2]: xx[8] = "Антон"
166165
a_1 = Shine(number=xx[0], href=xx[1], company=xx[8], shirina=xx[4], visota=xx[5],
167166
diametr=xx[6], price=xx[3], short_note=xx[2])
168167
a_1.save()
169168
r_count += 1
170169
b_1 = 'Получны новые данные! '
171-
time = datetime.now()
170+
time = datetime.now().strftime('%d-%m-%Y %H:%M')
171+
a_2 = Times.objects.all()
172+
a_2.delete()
173+
a_2 = Times(time1=time)
174+
a_2.save()
172175

173176
return render(request, 'cards/search.html',
174177
{"b_1": b_1, "r_count": r_count, "time": time})

site_cards/db.sqlite3

0 Bytes
Binary file not shown.

site_cards/media/4719539720.jpg

-457 KB
Binary file not shown.

0 commit comments

Comments
 (0)