Skip to content

Commit 9e4a993

Browse files
committed
Add questions possibility for other parenst
1 parent 0e8fd00 commit 9e4a993

File tree

4 files changed

+24
-9
lines changed

4 files changed

+24
-9
lines changed

database.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ class User(Document):
1515
last_name = StringField()
1616
state = StringField()
1717
role = StringField(choices=ROLES, default=ROLES[0])
18+
with_child_in_school = BooleanField(default=False)
1819
language = StringField(choices=LANGUAGES, default=LANGUAGES[0])

keyboards.py

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def get_parents_without_children_keyboard(language='ua'):
3030
keyboard.add(DICTIONARY[language]['excursion_button'])
3131
keyboard.add(DICTIONARY[language]['all_about_nush_btn'])
3232
keyboard.add(types.KeyboardButton(text=DICTIONARY[language]['choose_school_button'], request_location=True))
33+
keyboard.add(DICTIONARY[language]['ask_mon_question_btn'])
34+
keyboard.add(DICTIONARY[language]['rating_mon_question_btn'])
3335
keyboard.add(DICTIONARY[language]['back_button'])
3436
return keyboard
3537

languages.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,14 @@
9393
# mon
9494
'mon_button': 'МОН',
9595
'mon_msg': 'Можна почитати відповіді МОН або поставити своє питання.',
96-
'ask_mon_question_btn': '🥇 Запитати',
96+
'ask_mon_question_btn': ' Запитати',
9797
'ask_mon_question_msg': 'Запитайте шось.',
9898
'faq_mon_btn': 'FAQ',
9999
'faq_mon_msg': 'Відповідаємо на запитання. Робота в 2-му пілотному класі.'
100100
'<a href="http://nus.org.ua/questions/vidpovidayemo-na-zapytannya-robota-v-2-mu-pilotnomu-'
101101
'klasi/?fbclid=IwAR35EpzkYuIjXN5NWa0XeNdUPWJgT-xmbTp6s3A6b_qRtpDdu8KaVbdK9r4">'
102102
' - натисність сюди</a>',
103-
'rating_mon_question_btn': '📊 Рейтинг питань',
103+
'rating_mon_question_btn': '📊 ТОП питань до МОН',
104104
'rating_mon_question_msg': 'Тут буде рейтинг питань.',
105105

106106

states.py

+19-7
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from time import sleep
66

77

8-
98
def choose_status_state(message, user, is_entry=False):
109
if is_entry:
1110
bot.send_message(message.chat.id,
@@ -32,15 +31,21 @@ def choose_status_state(message, user, is_entry=False):
3231
'''
3332
PARENTS
3433
'''
34+
35+
3536
def parents_state(message, user, is_entry=False):
3637
if is_entry:
3738
bot.send_message(message.chat.id,
3839
DICTIONARY['ua']['is_children_msg'],
3940
reply_markup=get_parents_choose_keyboard('ua'))
4041
else:
4142
if message.text == DICTIONARY['ua']['is_children_button']:
43+
user.with_child_in_school = True
44+
user.save()
4245
return True, 'parents_with_children_state'
4346
elif message.text == DICTIONARY['ua']['no_children_button']:
47+
user.with_child_in_school = False
48+
user.save()
4449
return True, 'parents_without_children_state'
4550
else:
4651
bot.send_message(message.chat.id,
@@ -73,7 +78,6 @@ def parents_with_children_state(message, user, is_entry=False):
7378
return False, ''
7479

7580

76-
7781
def parents_without_children_state(message, user, is_entry=False):
7882
if is_entry:
7983
bot.send_message(message.chat.id,
@@ -87,8 +91,11 @@ def parents_without_children_state(message, user, is_entry=False):
8791
photo=open('img/excursion.png', 'rb'),
8892
caption=DICTIONARY['ua']['excursion_msg'],
8993
reply_markup=get_excursion_button_keyboard('ua'))
90-
elif message.text == DICTIONARY['ua']['choose_school_button']:
91-
pass
94+
elif message.text == DICTIONARY['ua']['ask_mon_question_btn']:
95+
return True, 'ask_mon_question_state'
96+
elif message.text == DICTIONARY['ua']['rating_mon_question_btn']:
97+
bot.send_message(message.chat.id,
98+
DICTIONARY['ua']['rating_mon_question_msg'])
9299
elif message.text == DICTIONARY['ua']['back_button']:
93100
return True, 'parents_state'
94101
else:
@@ -181,6 +188,8 @@ def thematic_sections_state(message, user, is_entry=False):
181188
"""
182189
TEACHERS
183190
"""
191+
192+
184193
def teachers_state(message, user, is_entry=False):
185194
if is_entry:
186195
bot.send_message(message.chat.id,
@@ -246,7 +255,7 @@ def mon_state(message, user, is_entry=False):
246255
if is_entry:
247256
bot.send_message(message.chat.id,
248257
DICTIONARY['ua']['mon_msg'],
249-
reply_markup=get_mon_keyboard('ua'))
258+
reply_markup=get_mon_keyboard('ua'))
250259
else:
251260
if message.text == DICTIONARY['ua']['ask_mon_question_btn']:
252261
return True, 'ask_mon_question_state'
@@ -276,7 +285,10 @@ def ask_mon_question_state(message, user, is_entry=False):
276285
else:
277286
if message.text == DICTIONARY['ua']['back_button']:
278287
if user.role == ROLES[0]:
279-
return True, 'parents_with_children_state'
288+
if user.with_child_in_school:
289+
return True, 'parents_with_children_state'
290+
elif user.with_child_in_school is False:
291+
return True, 'parents_without_children_state'
280292
elif user.role == ROLES[1]:
281293
return True, 'mon_state'
282-
return False, ''
294+
return False, ''

0 commit comments

Comments
 (0)