Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OLEG
moscowhack
backend
Commits
0cd44f9a
Commit
0cd44f9a
authored
Jun 12, 2022
by
CepbluKot
Browse files
added smth from Igor
parent
65368bcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
buisness_logic/advertisement_actions.py
deleted
100644 → 0
View file @
65368bcf
from
flask
import
jsonify
from
backend.models.all_models
import
Advertisement
from
web_setting
import
flask_app
,
db
def
create_advertisement
(
adv_info
):
new_advertisement
=
Advertisement
(
new_adv_name
=
adv_info
.
adv_name
,
new_time_event
=
adv_info
.
time_event
,
new_type_event
=
adv_info
.
type_event
,
new_employer_id
=
adv_info
.
employer_id
,
new_coordinates_id
=
adv_info
.
coordinates_id
,
new_categories_id
=
adv_info
.
categories_id
,
new_wait_size_users
=
adv_info
.
wait_size_users
)
db
.
session
.
add
(
new_advertisement
)
db
.
session
.
commit
()
return
jsonify
(
'advert add success'
)
buisness_logic/insert_models.py
View file @
0cd44f9a
from
web_setting
import
flask_app
,
db
from
models.all_models
import
Users
,
Employer
,
Customers
,
TagsUsers
,
ClickHistory
,
CommunityAdv
from
models.all_models
import
Advertisement
,
Users
,
Employer
,
Customers
,
TagsUsers
,
ClickHistory
,
CommunityAdv
from
werkzeug.security
import
generate_password_hash
,
check_password_hash
from
routers.all_dataclasses
import
EntryDate
,
TagsIndex
,
RepostEvent
...
...
@@ -52,6 +52,23 @@ def add_new_click(NewClick: TagsIndex):
db
.
session
.
commit
()
def
create_advertisement
(
adv_info
):
new_advertisement
=
Advertisement
(
new_adv_name
=
adv_info
.
adv_name
,
new_time_event
=
adv_info
.
time_event
,
new_type_event
=
adv_info
.
type_event
,
new_employer_id
=
adv_info
.
employer_id
,
new_coordinates_id
=
adv_info
.
coordinates_id
,
new_categories_id
=
adv_info
.
categories_id
,
new_wait_size_users
=
adv_info
.
wait_size_users
)
db
.
session
.
add
(
new_advertisement
)
db
.
session
.
commit
()
return
'advert add success'
""" 1) Подписка на комьюнити и инскрт новых коммьюнити
2) Создание новых объявлений
...
...
routers/advertisement_routers.py
View file @
0cd44f9a
...
...
@@ -35,7 +35,6 @@ def get_advertisement(adv_id=None):
return
jsonify
(
js_result
)
@
flask_app
.
route
(
'/api/advertisement/recommendations/<int:user_id>/'
,
methods
=
[
"GET"
])
def
rec_advertisement
(
user_id
=
None
):
...
...
@@ -80,3 +79,16 @@ def routers_advertisement():
return
jsonify
(
indexes_advertisments
(
id_adv
))
@
flask_app
.
route
(
'/api/advertisement/create/<string:adv_name>_<string:time_event>_<string:type_event>_<int:employer_id>_<int:coordinates>_<int:categories_id>_<int:wait_size_users>/'
,
methods
=
[
"GET"
,
"POST"
])
def
create_adv
(
adv_name
=
None
,
time_event
=
None
,
type_event
=
None
,
employer_id
=
None
,
coordinates
=
None
,
categories_id
=
None
,
wait_size_users
=
None
):
if
adv_name
is
not
None
and
time_event
is
not
None
and
type_event
is
not
None
and
employer_id
is
not
None
and
coordinates_id
is
not
None
and
categories_id
is
not
None
and
wait_size_users
:
print
(
'
\n\n
'
,
time_event
)
parsed_time_event
=
datetime
.
strptime
(
time_event
,
'%H:%M-%d-%m-%Y'
)
address
=
location_from_coordinates
(
coordinates
)
create_advertisement
(
adv_name
,
parsed_time_event
,
type_event
,
employer_id
,
coordinates_id
,
categories_id
,
wait_size_users
)
return
jsonify
(
"event created successfully"
)
return
jsonify
(
'Error'
),
401
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment