Changeset 2114
- Timestamp:
- 07/16/10 14:19:10 (19 months ago)
- Location:
- trunk/loreality
- Files:
-
- 2 added
- 6 edited
-
development.db (modified) (previous)
-
loreality/config/routing.py (modified) (1 diff)
-
loreality/controllers/messager.py (modified) (4 diffs)
-
loreality/public/js (added)
-
loreality/public/js/messager.js (added)
-
loreality/public/style.css (modified) (1 diff)
-
loreality/templates/base/index.html (modified) (2 diffs)
-
loreality/templates/derived/page/messager.html (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/loreality/loreality/config/routing.py
r2097 r2114 11 11 """Create, configure and return the routes Mapper""" 12 12 map = Mapper(directory=config['pylons.paths']['controllers'], 13 always_scan=config['debug'] )13 always_scan=config['debug'], explicit=True) 14 14 map.minimization = False 15 15 -
trunk/loreality/loreality/controllers/messager.py
r2113 r2114 21 21 import uuid 22 22 from pylons.i18n.translation import _, ungettext 23 from webhelpers.html.tags import literal 23 24 24 25 class MessagerController(BaseController): … … 61 62 return render('/derived/page/messager.html') 62 63 #-------------------------------------------------------------- 63 def open(self, id):64 return self.index(opened=uuid.UUID(id))65 #--------------------------------------------------------------66 64 @jsonify 67 65 def getallmsgs(self): … … 77 75 for m in messages: 78 76 p = pilot_q.filter_by(id=m.from_).first() 79 res['messages'].append({ 'date': m.date.strftime("%c"), 'from':p.name, 'subject':m.subject }) 77 res['messages'].append({ 78 'date': m.date.strftime("%c"), 79 'from':p.name, 80 'subject':m.subject, 81 'unread':m.unread, 82 'id':str(m.id), 83 }) 80 84 return res 81 85 #-------------------------------------------------------------- 86 @jsonify 82 87 def getmsg(self, id): 83 88 pilot_q = meta.Session.query(model.Pilot) 84 89 pilot = pilot_q.filter_by(login=request.environ['REMOTE_USER']).first() 85 90 if pilot is None: 86 abort(404)91 return "Error" 87 92 88 93 message_q = meta.Session.query(model.Message) … … 98 103 message.unread = False 99 104 meta.Session.commit() 100 return "%s|%s|%s"% ( str(message.id), message.text, pilot.messages_unread ) 105 106 p = pilot_q.filter_by(id=message.from_).first() 107 res = {} 108 res['message'] = { 109 'unread':p.messages_unread, 110 'id':str(message.id), 111 'text':literal(message.text), 112 } 113 return res 114 #-------------------------------------------------------------- 115 def reply(self, id): 116 pilot_q = meta.Session.query(model.Pilot) 117 pilot = pilot_q.filter_by(login=request.environ['REMOTE_USER']).first() 118 if pilot is None: 119 return "Error" 120 121 message_q = meta.Session.query(model.Message) 122 message = message_q.filter_by(id=uuid.UUID(id)).first() 123 if message is None: 124 return "Error" 125 126 #- Be sure it is our message 127 if message not in pilot.messages: return "Error" 128 129 values = dict(request.params) 130 131 pilotid = message.from_ 132 dest_pilot = pilot_q.filter_by(id=pilotid).first() 133 msg = model.Message() 134 msg.from_ = pilot.id 135 msg.subject = _("Re:") + message.subject 136 msg.text = values["text"] 137 dest_pilot.send_message( msg ) 138 meta.Session.commit() 139 return "ok" 101 140 #-------------------------------------------------------------- 102 141 def delete(self, id): -
trunk/loreality/loreality/public/style.css
r2112 r2114 66 66 67 67 /* MESSAGER */ 68 div.message_box { 69 display: right; 70 font-size: x-small; 71 } 72 div.message { 73 display: inline; 74 /* border: solid black 1px; */ 75 width: 80%; 76 /* background: #AAAAAA; */ 77 font-size: small; 78 } 79 80 div.message a{ 81 text-decoration:none ; 82 } 83 div.message span#subject { 84 font-weight: bold; 85 font-size: large; 86 margin-right: 30px; 87 } 88 span.read{ 68 .read{ 89 69 font-weight: normal; 90 70 background: #AAAAAA; 91 71 } 92 span.unread{72 .unread{ 93 73 font-weight: bold; 94 74 color: #aa1111; 95 75 background: #ffffff; 96 76 } 97 div.message_open{ 98 width: 80%; 99 border: solid black 1px; 100 background: #ffffff; 101 color: #000000; 102 margin-bottom: 20px; 77 78 .from .subject{ 79 text-align: left; 103 80 } 104 div.message_open span{ 105 color: red; 106 font-size: large; 81 .date{ 82 text-align: right; 107 83 } 108 84 .message_open { 85 border-left: solid 3px darkGrey; 86 padding-left: 5px; 87 background: #909090; 88 } 89 table#message_table { 90 width: 100%; 91 margin-left: 5px; 92 margin-right: 5px; 93 } -
trunk/loreality/loreality/templates/base/index.html
r2113 r2114 10 10 <html> 11 11 <head> 12 ${ h.stylesheet_link( '/style.css') } 13 <style type="text/css"> 14 @import "dojoroot/dijit/themes/tundra/tundra.css"; 15 @import "dojoroot/dojo/resources/dojo.css"; 16 </style> 12 ${ h.stylesheet_link( '/style.css', 13 "/dojo/dijit/themes/tundra/tundra.css", 14 "/dojo/dojo/resources/dojo.css") } 17 15 18 16 ${ h.javascript_link( '/dojo/dojo/dojo.js', djConfig="parseOnLoad: true") } … … 21 19 dojo.require("dijit.form.Button"); 22 20 dojo.require("dijit.Editor"); 21 dojo.require("dijit._editor.plugins.AlwaysShowToolbar"); 23 22 dojo.require("dojo.fx"); 24 23 dojo.require("dojo.html"); -
trunk/loreality/loreality/templates/derived/page/messager.html
r2113 r2114 1 1 <%inherit file="/base/index.html"/> 2 3 <script> 4 /*-------------------------------------*/ 5 function showMessage(data,ioArgs) { 6 if( data == "Error"){ 7 alert("Error"); 8 }else{ 9 d = data.split('|'); 10 dojo.fx.wipeIn({ 11 node:"message-" + d[0], 12 beforeBegin: function(n){ 13 dojo.byId("message-txt-"+d[0]).innerHTML = d[1]; 14 } 15 }).play(); 16 dojo.byId( "nb_msg_unread").innerHTML = d[2]; 17 } 18 19 } 20 /*-------------------------------------*/ 21 function helloError(data, ioArgs) { 22 alert('Error when retrieving data from the server!'); 23 } 24 /*-------------------------------------*/ 25 function loadMsg() { 26 dojo.empty("message_table"); 27 dojo.xhrGet({ 28 url: '${h.url_for(controller='messager', action='getallmsgs') }', 29 load: fillMessages, 30 error: helloError, 31 }).play(); 32 } 33 dojo.addOnLoad( loadMsg ); 34 /*-------------------------------------*/ 35 function fillMessages(data,ioArgs) { 36 if( data == "Error"){ 37 alert("Error"); 38 }else{ 39 objects = dojox.json.ref.fromJson(data); 40 messages = objects['messages']; 41 42 var buffer = ""; 43 for (i = 0; i < messages.length; i += 1) { 44 msg = messages[i]; 45 buffer += "<tr><td>" + msg['date'] + '</td><td>' + msg['from'] + '</td><td>' + msg['subject'] +"</td></tr>" 46 } 47 dojo.html.set("message_table", buffer); 48 49 } 50 } 51 </script> 52 2 ${ h.javascript_link( '/js/messager.js') } 53 3 <h2>Messager</h2> 54 % for message in c.messages:55 <div class="message">56 <a href=${h.url_for(controller='messager', action='delete',id=message.id) } class="action">[Delete]</a>57 <button dojoType="dijit.form.ToggleButton">58 <span59 %if message.unread:60 class="unread"61 %else:62 class="read"63 %endif64 id="span-${message.id}" >${h.msg.get_from(message)} | ${message.date.strftime("%c")} | <span id="subject"> ${message.subject}</span></span>65 66 <script type="dojo/method" event="onChange">67 node = "span-${message.id}";68 if( this.checked )69 {70 if( dojo.hasClass( node, "unread") )71 {72 dojo.removeClass( node, "unread");73 dojo.addClass( node, "read");74 }75 dojo.xhrGet({76 url: '${h.url_for(controller='messager', action='getmsg',id=message.id) }',77 load: showMessage,78 error: helloError,79 }).play();80 }else{81 dojo.fx.wipeOut({82 node:"message-${message.id}",83 }).play();84 }85 </script>86 </button>87 </div>88 <div id="message-${message.id}" class='message_open' style="display: none;">89 <button dojoType="dijit.form.Button">Reply90 <script type="dojo/method" event="onClick">91 </script>92 </button>93 <p id="message-txt-${message.id}"></p>94 </div>95 <br/>96 % endfor97 <h2>New one</h2>98 4 <div id="message_list"> 99 5 <table id="message_table">
Note: See TracChangeset
for help on using the changeset viewer.
