view.html
{{extend "layout.html"}}
{{for q in question:}}
{{q=XML(q.quest.replace('\n','<br>').replace('(','{').replace(')','}'),
sanitize=True)}}
{{pass}}
{{for a in answer:}}
{{a=XML(a.message.replace('\n','<br>').replace('(','{').replace(')','}'),
sanitize=True)}}
{{pass}}
<html lang="en">
<meta charset="utf-8"/>
<style type="text/css">
* {
box-sizing: border-box;
}
body {
background-color: #edeff2;
font-family: 'Noto Serif', serif;
font-size: 0.3em;
font-weight: lighter;
overflow-y:hidden;
}
.chat_window {
position: fixed;
width: calc(100% - 20px);
max-width: 90%px;
height: 440px;
border-radius: 10px;
background-color: #fff;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
background-color: #f8f8f8;
overflow: hidden;
bottom:0;
}
.messages {
position: relative;
list-style: none;
padding: 20px 10px 0 10px;
margin: 0;
height: 390px;
overflow-y: scroll;
}
.messages::-webkit-scrollbar {
display: none;
}
.messages .message {
clear: both;
overflow: hidden;
margin-bottom: 20px;
transition: all 0.5s linear;
opacity: 0;
font-size: 0.5em;
}
.messages .message.left .text_wrapper {
background-color: #8C9EFF;
margin-left: 2px;
}
.messages .message.left .text_wrapper::after, .messages .message.left
.text_wrapper::before {
right: 100%;
border-right-color: #8C9EFF;
}
.messages .message.left .text {
color: white;
}
.messages .message.right .text_wrapper {
background-color: #E8EAF6;
margin-right: 2px;
float: right;
max-width: 89%;
width: auto;
position: relative;
word-wrap: break-word;
word-spacing: normal;
text-align:justify;
max-height: 150px;
height:auto;
display: inline-block;
padding: 6px;
border-radius: 7px;
}
.messages .message.right .text_wrapper::-webkit-scrollbar{
display:none;
}
.messages .message.right .text_wrapper::after, .messages .message.right
.text_wrapper::before {
left: 100%;
border-left-color: #E8EAF6;
}
.messages .message.right .text {
color: black;
font-size: 1em;
}
.messages .message.appeared {
opacity: 1;
}
.messages .message .message_data_time {
margin-right:0;
margin-top:0;
position: relative;
right:5px;
display: inline-block;
}
.messages .message .text_wrapper {
display: inline-block;
max-height: 150px;
border-radius: 6px;
width:auto;
overflow-y: auto;
text-align:justify;
position: relative;
word-wrap: break-word;
word-spacing: normal;
padding:4px;
line-height: 16px;
}
.messages .message .text_wrapper::-webkit-scrollbar{
display:none;
}
.messages .message .text_wrapper::after, .messages .message
.text_wrapper:before {
top: 18px;
border: solid transparent;
height: 0;
width: 0;
position: absolute;
pointer-events: none;
}
.messages .message .text_wrapper::after {
border-width: 13px;
margin-top: 0px;
}
.messages .message .text_wrapper::before {
border-width: 15px;
margin-top: 2px;
}
.messages .message .text_wrapper .text {
font-size: 18px;
font-weight: 300;
}
.bottom_wrapper {
position: relative;
width: 100%;
background-color: #fff;
padding: 10px 10px;
position: absolute;
bottom: 0;
}
.message_input_wrapper textarea {
border: 1px solid #bcbdc0;
padding: 10px 10px;
font: 16px/22px "Lato", Arial, sans-serif;
margin-bottom: 2px;
border-radius: 5px;
height: 45px;
box-sizing: border-box;
width: 82%;
max-width: 82%;
position: relative;
outline-width: 0;
color: black;
top:5px;
bottom: 10px;
}
.message_input_wrapper button {
border: none;
padding: 8px 2px;
float: right;
border-radius: 5px;
height: 45px;
box-sizing: border-box;
width: 15.5%;
max-width: 15.5%;
position: relative;
outline-width: 0;
color: white;
font-size: 16px;
cursor: pointer;
background: #8C9EFF;
top:5px;
bottom: 10px;
}
.bottom_wrapper .message_input_wrapper .message_input {
border: none;
height: 100%
box-sizing: border-box;
width: calc(100% - 40px);
position: absolute;
outline-width: 0;
color: gray;
}
.bottom_wrapper .send_message {
width: 140px;
height: 40px;
display: inline-block;
border-radius: 50px;
background-color: #a3d063;
border: 2px solid #a3d063;
color: #fff;
cursor: pointer;
transition: all 0.2s linear;
text-align: center;
float: right;
}
.bottom_wrapper .send_message:hover {
color: #a3d063;
background-color: #fff;
}
.bottom_wrapper .send_message .text {
font-size: 18px;
font-weight: 300;
display: inline-block;
line-height: 48px;
}
.message_template {
display: none;
}
</style>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="
http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js
"></script>
</head>
<body>
<div class="chat_window">
<ul class="messages">
{{for reply in replies:}}
<li class="message left appeared">
<div>
{{=prettydate(reply.modified_on)}}
</div>
<div class="text_wrapper">
<div
class="text">{{=XML(reply.quest.replace('\n','<br>').replace('(','{').replace(')','}'),
sanitize=True)}}</div>
</div>
</li>
<li class="message right appeared">
<div>
{{=prettydate(reply.modified_on)}}
</div>
<div class="text_wrapper">
<div
class="text">{{=XML(reply.message.replace('\n','<br>').replace('(','{').replace(')','}'),
sanitize=True)}}</div>
</div>
</li>
{{pass}}
</ul>
<div class="bottom_wrapper clearfix">
<div class="message_input_wrapper">
<div class="message_input_wrapper">
{{=form.custom.begin}}
<textarea name="message" id="message_input"
placeholder="Type your message here..."></textarea>
<button>send</button>
{{=form.custom.end}}
</div>
</div>
</div>
</div>
<div class="message_template">
<li class="message">
<div class="message-data-time" ></div>
<div class="text_wrapper">
<div class="text"></div>
</div>
</li>
</div>
<script type="text/javascript">
(function () {
var Message;
Message = function (arg) {
this.text = arg.text, this.message_side = arg.message_side;
this.draw = function (_this) {
return function () {
var $message;
$message = $($('.message_template').clone().html());
$message.addClass(_this.message_side).find('.text').html(_this.text);
$('.messages').append($message);
return setTimeout(function () {
return $message.addClass('appeared');
}, 0);
};
}(this);
return this;
};
$(function () {
var getMessageText, message_side, sendMessage;
message_side = 'right';
getMessageText = function () {
var $message_input;
$message_input = $('.message_input');
return $message_input.val();
};
sendMessage = function (text) {
var $messages, message;
if (text.trim() === '') {
return;
}
$('.message_input').val('');
$messages = $('.messages');
message_side = message_side === 'left' ? 'right' : 'left';
message = new Message({
text: text,
message_side: message_side
});
message.draw();
return $messages.animate({ scrollTop:
$messages.prop('scrollHeight') }, 10);
};
$('.send_message').click(function (e) {
return sendMessage(getMessageText());
});
$('.message_input').keyup(function (e) {
if (e.which === 13) {
return sendMessage(getMessageText());
}
});
sendMessage('{{=q}}');
setTimeout(function () {
return sendMessage('{{=a}}');
}, 1500);
});
}.call(this));
</script>
</body>
</html>
On Sat, Apr 7, 2018 at 5:08 AM, Maurice Waka <[email protected]> wrote:
> Sorry , I was taking a shortcut to avoid posting much code.
> Here it is, a different app still with the same issue..
>
> def index():
> return locals()
> @auth.requires_membership('managers')#->this gives an erros bout q not
> being defined in view_searches
> def my_notes():
> dbwellnesshealth.health.id.readable = False
> g = SQLFORM.grid(dbwellnesshealth.health, searchable=True, csv=False,
> user_signature=True, )
> return dict(form = g)
> @auth.requires_login()
> def upd_healthinsure():
> id,column = request.post_vars.id.split('.')
> value = request.post_vars.value
> dbwellnesshealth(dbwellness.health.id == id).update(**{column:value})
> return value
> @auth.requires_login()
> def about():
> return dict(message=T('Welcome to Home!'))
> @auth.requires_login()
> def view_searches():
> if db(db.post).isempty():
> db.post.insert(message="Hi, it's" +' ' +auth.user.first_name+' '+
> 'loging in...')# Some times after deleting the questions we get an error
> about list index outof range when starting afresh. Hence this.
> form = SQLFORM(Post, formstyle='table3cols',)
> if form.process().accepted:
> pass
> name3 = 'testing this app 123'
> def searches_process():
> for item in [name3][0]:
> if '123' in item:
> return name3
> else:
> return "Ooops! no answer!"
> report = searches_process()
> db.answers.insert(quest=name3, message=report)
> replies = db(db.answers.author == auth.user.id).select(db.
> answers.ALL)[-5:-1]
> question = db(db.answers.author == auth.user.id).select(orderby=~
> db.answers.created_on,limitby=(2,0))
> answer = db(db.answers.author ==
> auth.user.id).select(orderby=~db.answers.created_on,
> limitby=(2,0))
> return dict(form=form, question=question, answer=answer,
> replies=replies)
>
> Traceback
>
> 1.
> 2.
> 3.
> 4.
> 5.
> 6.
> 7.
>
> Traceback (most recent call last):
> File "/home/maurice/web2py/gluon/restricted.py", line 219, in restricted
> exec(ccode, environment)
> File
> "/home/maurice/web2py/applications/Hestque_Wellness/views/default/view_searches.html",
> line 103, in <module>
> display: inline-block;
> NameError: name 'q' is not defined
>
>
>
> As for the view:
>
>
> {{extend "layout.html"}}
>
> {{for q in question:}}
> {{q=XML(q.quest.replace('\n','<br>').replace('(','{').replace(')','}'),
> sanitize=True)}}
> {{pass}}
> {{for a in answer:}}
> {{a=XML(a.message.replace('\n','<br>').replace('(','{').replace(')','}'),
> sanitize=True)}}
> {{pass}}
> <html lang="en">
> <meta charset="utf-8"/>
>
> <style type="text/css">
> * {
> box-sizing: border-box;
> }
> body {
> background-color: #edeff2;
> font-family: 'Noto Serif', serif;
> font-size: 0.3em;
> font-weight: lighter;
> overflow-y:hidden;
> }
> .chat_window {
> position: fixed;
> width: calc(100% - 20px);
> max-width: 90%px;
> height: 440px;
> border-radius: 10px;
> background-color: #fff;
> left: 50%;
> top: 50%;
> transform: translateX(-50%) translateY(-50%);
> box-shadow: 0 10px 20px rgba(0, 0, 0, 0.15);
> background-color: #f8f8f8;
> overflow: hidden;
> bottom:0;
> }
> .messages {
> position: relative;
> list-style: none;
> padding: 20px 10px 0 10px;
> margin: 0;
> height: 390px;
> overflow-y: scroll;
> }
> .messages::-webkit-scrollbar {
> display: none;
> }
> .messages .message {
> clear: both;
> overflow: hidden;
> margin-bottom: 20px;
> transition: all 0.5s linear;
> opacity: 0;
> font-size: 0.5em;
> }
> .messages .message.left .text_wrapper {
> background-color: #8C9EFF;
> margin-left: 2px;
> }
> .messages .message.left .text_wrapper::after, .messages .message.left
> .text_wrapper::before {
> right: 100%;
> border-right-color: #8C9EFF;
> }
> .messages .message.left .text {
> color: white;
> }
> .messages .message.right .text_wrapper {
> background-color: #E8EAF6;
> margin-right: 2px;
> float: right;
> max-width: 89%;
> width: auto;
> position: relative;
> word-wrap: break-word;
> word-spacing: normal;
> text-align:justify;
> max-height: 150px;
> height:auto;
> display: inline-block;
> padding: 6px;
> border-radius: 7px;
> }
> .messages .message.right .text_wrapper::-webkit-scrollbar{
> display:none;
> }
> .messages .message.right .text_wrapper::after, .messages .message.right
> .text_wrapper::before {
> left: 100%;
> border-left-color: #E8EAF6;
> }
> .messages .message.right .text {
> color: black;
> font-size: 1em;
> }
> .messages .message.appeared {
> opacity: 1;
> }
> .messages .message .message_data_time {
> margin-right:0;
> margin-top:0;
> position: relative;
> right:5px;
> display: inline-block;
> }
> .messages .message .text_wrapper {
> display: inline-block;
> max-height: 150px;
> border-radius: 6px;
> width:auto;
> overflow-y: auto;
> text-align:justify;
> position: relative;
> word-wrap: break-word;
> word-spacing: normal;
> padding:4px;
> line-height: 16px;
> }
> .messages .message .text_wrapper::-webkit-scrollbar{
> display:none;
> }
> .messages .message .text_wrapper::after, .messages .message
> .text_wrapper:before {
> top: 18px;
> border: solid transparent;
> height: 0;
> width: 0;
> position: absolute;
> pointer-events: none;
> }
> .messages .message .text_wrapper::after {
> border-width: 13px;
> margin-top: 0px;
> }
> .messages .message .text_wrapper::before {
> border-width: 15px;
> margin-top: 2px;
> }
> .messages .message .text_wrapper .text {
> font-size: 18px;
> font-weight: 300;
> }
> .bottom_wrapper {
> position: relative;
> width: 100%;
> background-color: #fff;
> padding: 10px 10px;
> position: absolute;
> bottom: 0;
> }
> .message_input_wrapper textarea {
> border: 1px solid #bcbdc0;
> padding: 10px 10px;
> font: 16px/22px "Lato", Arial, sans-serif;
> margin-bottom: 2px;
> border-radius: 5px;
> height: 45px;
> box-sizing: border-box;
> width: 82%;
> max-width: 82%;
> position: relative;
> outline-width: 0;
> color: black;
> top:5px;
> bottom: 10px;
> }
> .message_input_wrapper button {
> border: none;
> padding: 8px 2px;
> float: right;
> border-radius: 5px;
> height: 45px;
> box-sizing: border-box;
> width: 15.5%;
> max-width: 15.5%;
> position: relative;
> outline-width: 0;
> color: white;
> font-size: 16px;
> cursor: pointer;
> background: #8C9EFF;
> top:5px;
> bottom: 10px;
> }
> .bottom_wrapper .message_input_wrapper .message_input {
> border: none;
> height: 100%
> box-sizing: border-box;
> width: calc(100% - 40px);
> position: absolute;
> outline-width: 0;
> color: gray;
> }
> .bottom_wrapper .send_message {
> width: 140px;
> height: 40px;
> display: inline-block;
> border-radius: 50px;
> background-color: #a3d063;
> border: 2px solid #a3d063;
> color: #fff;
> cursor: pointer;
> transition: all 0.2s linear;
> text-align: center;
> float: right;
> }
> .bottom_wrapper .send_message:hover {
> color: #a3d063;
> background-color: #fff;
> }
> .bottom_wrapper .send_message .text {
> font-size: 18px;
> font-weight: 300;
> display: inline-block;
> line-height: 48px;
> }
> .message_template {
> display: none;
> }
> </style>
> <script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
> <script
> src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
> </head>
>
>
>
> On Sat, Apr 7, 2018 at 12:01 AM, Anthony <[email protected]> wrote:
>
>> @auth.requires_login()
>>> def notes():
>>> dbhealth.health.id.readable = False
>>> g = SQLFORM.grid(dbhealth.health, searchable=True, csv=False,
>>> user_signature=True, )
>>> return dict(form = g)........code
>>> question = db(db.answers.author == auth.user.id).select(orderby=~
>>> db.answers.created_on,limitby=(2,0))
>>> return dict(form=form, question=question)
>>>
>>
>> The above is not valid Python code. Please show the real code.
>>
>> Anthony
>>
>> --
>> Resources:
>> - http://web2py.com
>> - http://web2py.com/book (Documentation)
>> - http://github.com/web2py/web2py (Source code)
>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>> ---
>> You received this message because you are subscribed to a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/to
>> pic/web2py/YQhEantsews/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.