init
This commit is contained in:
163
BaseModels/messages.py
Normal file
163
BaseModels/messages.py
Normal file
@@ -0,0 +1,163 @@
|
||||
## -*- coding: utf-8 -*-
|
||||
__author__ = 'SDE'
|
||||
# from Baldenini_site.inter import jsonify
|
||||
|
||||
def get_error_message_Dict(show_icon=None):
|
||||
print('get_error_message_Dict')
|
||||
Dict = {
|
||||
'form_style' : u'border-color: #FFBBBB; background-color: #FFEAEA;',
|
||||
}
|
||||
if show_icon:
|
||||
Dict.update({
|
||||
'form_icon' : 'canceled.png',
|
||||
})
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
def get_good_message_Dict(show_icon=None):
|
||||
Dict = {
|
||||
'form_style' : u'border-color: #BBFFBB; background-color: #EAFFEA;',
|
||||
}
|
||||
|
||||
if show_icon:
|
||||
Dict.update({
|
||||
'form_icon' : 'accepted.png',
|
||||
})
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
def get_return_to_ready_but():
|
||||
return {
|
||||
'buttons' : u'<div class="button close">ГОТОВО</div>'
|
||||
}
|
||||
|
||||
|
||||
def get_return_to_choice_buts(but_ok_name, but_cancel_name):
|
||||
return {
|
||||
'buttons' : u'<div class="button ok">{0}</div>'
|
||||
u'<div class="button cancel">{1}</div>'.format(but_ok_name, but_cancel_name)
|
||||
}
|
||||
|
||||
|
||||
def get_error_message(caption, text, show_icon=None):
|
||||
|
||||
Dict = {
|
||||
'message' : text,
|
||||
'caption' : caption
|
||||
}
|
||||
Dict.update(get_error_message_Dict(show_icon))
|
||||
Dict.update(get_return_to_ready_but())
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
# @jsonify()
|
||||
def show_error_message(caption, text, show_icon=None):
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
return {'error':'error',
|
||||
'html': render_to_string(
|
||||
'm_show_message.html',
|
||||
get_error_message(caption, text, show_icon)
|
||||
)
|
||||
}
|
||||
|
||||
# @jsonify()
|
||||
def show_good_message(caption, text):
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
return {'html': render_to_string(
|
||||
'm_show_message.html',
|
||||
get_good_message(caption, text)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def show_good_message_ok_go_to_blank_page(caption, text, button_caption, url):
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
return {'html': render_to_string(
|
||||
'm_show_message.html',
|
||||
get_good_message_ok_go_to_blank_page(caption, text, button_caption, url)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
# def show_choice_message_w_input(caption, text, but_ok_name, but_cancel_name, form):
|
||||
# from django.template.loader import render_to_string
|
||||
#
|
||||
# return {'html': render_to_string(
|
||||
# 'Messages/m_show_message.html',
|
||||
# get_choice_message(caption, text, but_ok_name, but_cancel_name)
|
||||
# )
|
||||
# }
|
||||
|
||||
|
||||
def show_choice_message_green(caption, text, but_ok_name, but_cancel_name, form=None):
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
return {'html': render_to_string(
|
||||
'm_show_message.html',
|
||||
get_choice_message(caption, text, but_ok_name, but_cancel_name, form, u'green')
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def show_choice_message_red(caption, text, but_ok_name, but_cancel_name, form=None):
|
||||
from django.template.loader import render_to_string
|
||||
|
||||
return {'html': render_to_string(
|
||||
'm_show_message.html',
|
||||
get_choice_message(caption, text, but_ok_name, but_cancel_name, form, u'red')
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
def get_choice_message(caption, text, but_ok_name, but_cancel_name, form=None, color=u'red', show_icon=None):
|
||||
|
||||
Dict = {
|
||||
'message' : text,
|
||||
'caption' : caption,
|
||||
'form' : form
|
||||
}
|
||||
|
||||
if color == u'red':
|
||||
Dict.update(get_error_message_Dict(show_icon))
|
||||
elif color == u'green':
|
||||
Dict.update(get_good_message_Dict(show_icon))
|
||||
|
||||
Dict.update(get_return_to_choice_buts(but_ok_name, but_cancel_name))
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
def get_but_ok_go_to_blank_page(button_caption, url):
|
||||
return {
|
||||
'buttons' : u'<p class="button_box"><a target="_blank" class="button close" href="/restaurant_control/users_control/show_users_report/{0}">{1}</a></p>'.format(url,button_caption)
|
||||
}
|
||||
|
||||
|
||||
def get_good_message_ok_go_to_blank_page(caption, text, button_caption, url, show_icon=None):
|
||||
|
||||
Dict = {
|
||||
'message' : text,
|
||||
'caption' : caption
|
||||
}
|
||||
Dict.update(get_good_message_Dict(show_icon))
|
||||
Dict.update(get_but_ok_go_to_blank_page(button_caption, url))
|
||||
|
||||
return Dict
|
||||
|
||||
|
||||
def get_good_message(caption, text, show_icon=None):
|
||||
|
||||
Dict = {
|
||||
'message' : text,
|
||||
'caption' : caption
|
||||
}
|
||||
Dict.update(get_good_message_Dict(show_icon))
|
||||
Dict.update(get_return_to_ready_but())
|
||||
|
||||
return Dict
|
||||
Reference in New Issue
Block a user