Changeset 2111


Ignore:
Timestamp:
07/13/10 14:56:21 (19 months ago)
Author:
dart
Message:

LoReality?:
o Implement notifications
o Begin integration of ajax fmw dojo

Location:
trunk/loreality
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/loreality/loreality/controllers/messager.py

    r2109 r2111  
    4646            abort(404) 
    4747 
     48        c.heading = _("Messager") 
    4849        c.messages = pilot.messages  
    4950        c.message_open = opened 
     51 
     52        #- Treat unread field 
     53        message_q = meta.Session.query(model.Message) 
     54        message = message_q.filter_by(id=opened).first() 
     55        if message: 
     56            if message.unread: 
     57                pilot.messages_unread -= 1 
     58                message.unread = False 
     59                meta.Session.commit() 
    5060        return render('/derived/page/messager.html') 
    5161    #-------------------------------------------------------------- 
     
    7484            pilot = pilot_q.filter_by(login=request.environ['REMOTE_USER']).first() 
    7585            if pilot is None: 
    76                 return " pilot"  
    7786                abort(404) 
    7887 
     
    97106        values['Pilot'] = current_pilot 
    98107 
     108        c.heading = _("New message") 
    99109        c.formfields = self.formfields 
    100110        c.available_pilots = self._get_pilots() 
  • trunk/loreality/loreality/controllers/mission.py

    r2109 r2111  
    1212 
    1313import loreality.lib.helpers as h 
     14from webhelpers.html.tags import stylesheet_link, literal, link_to 
     15from webhelpers.html.builder import make_tag 
    1416from loreality.model.form import * 
    1517 
     
    2123import uuid 
    2224from pylons.i18n.translation import _, ungettext 
     25from pylons import session 
     26 
    2327class MissionController(BaseController): 
    2428    formfields = [ 
     
    103107 
    104108        c.title = "LoReality" 
    105         c.heading = "Edit %s"%mission.name 
     109        c.heading = _("Edit %s")%mission.name 
    106110        c.mission = mission 
    107111        c.formfields = self.formfields 
     
    133137        if pilot is None: 
    134138            abort(404) 
     139         
    135140        
    136141        #- del now 
    137142        mission.pilots.append( pilot ) 
     143 
     144        #- Notify 
     145        h.msg.notify(  
     146            pilot.id, 
     147            subject=_("Participation for mission") + " %s"%mission.name,  
     148            text = _("You have been selected to participate to the mission ") + h.msg.make_link(mission.name, h.url_for(controller='mission', action='view', id=mission.id)), 
     149            commit=False) 
     150 
     151        session['flash'] = _('Pilot %s added to the mission')%pilot.name 
     152        session.save() 
     153 
    138154        meta.Session.commit() 
    139155        return self.edit( id ) 
     
    159175        #- del now 
    160176        mission.pilots.remove( pilot ) 
     177        session['flash'] = _('Pilot %s removed of the mission')%pilot.name 
     178        session.save() 
    161179        meta.Session.commit() 
    162180        return self.edit( id ) 
  • trunk/loreality/loreality/lib/helpers.py

    r2109 r2111  
    1010from loreality.lib import auth 
    1111from loreality.lib import msg 
    12 from webhelpers.html.tags import stylesheet_link 
     12from webhelpers.html.tags import stylesheet_link, javascript_link, literal, link_to 
    1313 
    1414 
  • trunk/loreality/loreality/lib/msg.py

    r2109 r2111  
    44from loreality.model import meta 
    55import loreality.model as model 
     6from pylons import request 
     7from webhelpers.html.tags import stylesheet_link, literal, link_to 
    68 
    79 
     
    3234    meta.Session.commit() 
    3335 
     36def notify(pilotid, subject, text, commit=True): 
     37    pilot_q = meta.Session.query(model.Pilot) 
     38    me = pilot_q.filter_by(login=request.environ['REMOTE_USER']).first() 
     39     
     40    #- Make message 
     41    message = model.Message(  
     42            from_=me.id,  
     43            subject=subject, 
     44            text = text 
     45            ) 
     46    meta.Session.add( message ) 
     47    pilot = pilot_q.filter_by(id=pilotid).first() 
     48    if pilot is None: return 
     49 
     50    pilot.send_message(message) 
     51    if commit: 
     52        meta.Session.commit() 
     53def make_link( title, link ): 
     54    return link_to(title, url=link) 
  • trunk/loreality/loreality/model/databases.py

    r2109 r2111  
    100100    pilot_id = sa.Column(UUID(), ForeignKey('pilots.id')) 
    101101 
    102     def __init__(self): 
     102    def __init__(self, from_=None, subject=None, text=None): 
    103103        self.unread = True 
     104        if from_: 
     105            self.from_ = from_ 
     106        if subject: 
     107            self.subject = subject 
     108        if text: 
     109            self.text = text 
    104110 
    105111    def copy(self): 
  • trunk/loreality/loreality/public/style.css

    r2109 r2111  
    1212  
    1313} 
     14 
     15#flash { 
     16    background: #ffc; 
     17     color: #000000; 
     18    padding: 5px; 
     19    border: 1px dotted #000; 
     20    margin-bottom: 20px; 
     21} 
     22#flash p { margin: 0px; padding: 0px; } 
    1423 
    1524/* MENU */ 
     
    6978} 
    7079 
     80div.message a{ 
     81    text-decoration:none ; 
     82} 
    7183div.message span#subject { 
    7284    font-weight: bold; 
    7385    font-size: large; 
    7486    margin-right: 30px; 
     87} 
     88span.unread a{ 
     89    font-weight: bold; 
     90     background: #ffffff; 
    7591} 
    7692div.message_open{ 
     
    8399div.message_open span{ 
    84100 color: red; 
     101    font-size: large; 
    85102} 
    86103 
  • trunk/loreality/loreality/templates/base/index.html

    r2109 r2111  
    1111<head> 
    1212${ h.stylesheet_link( '/style.css') } 
     13${ h.javascript_link( '/dojo/dojo/dojo.js', djConfig="parseOnLoad: true") } 
    1314    <title>${self.title()}</title> 
    1415    ${self.head()} 
    1516</head> 
    1617<body> 
     18 
    1719    <div id="hd"> 
    1820        <div class="yui-gc"> 
     
    3840    </div> 
    3941    ${self.menu()} 
     42    ${self.flash()} 
    4043    ${next.body()} 
    4144    ${self.footer()} 
     
    5053<%def name="heading()"><h1>${c.heading or 'No Title'}</h1></%def> 
    5154<%def name="footer()"><p><a href="#top">Top ^</a></p></%def> 
     55 
     56<%def name="flash()"> 
     57    % if session.has_key('flash'): 
     58    <div id="flash"><p>${session.get('flash')}</p></div> 
     59    <% 
     60        del session['flash'] 
     61        session.save() 
     62    %> 
     63    % endif 
     64</%def> 
  • trunk/loreality/loreality/templates/derived/page/messager.html

    r2109 r2111  
    88<div class="message"> 
    99% endif 
     10    <a href=${h.url_for(controller='messager', action='delete',id=message.id) } class="action">[Delete]</a> 
    1011% if message.id == c.message_open: 
    1112<span><a href=${h.url_for(controller='messager', action='index',id=message.id) } class="action">${h.msg.get_from(message)} | ${message.date.strftime("%c")}  <span id="subject">${message.subject}</span></a></span> 
    12     <div id="text">${message.text}</div> 
     13    <div id="text">${h.literal(message.text)}</div> 
    1314    <a href=${h.url_for(controller='messager', action='create',id=message.id) } class="action">[Reply]</a> 
    1415% else: 
    15 <span><a href=${h.url_for(controller='messager', action='open',id=message.id) } class="action">${h.msg.get_from(message)} | ${message.date.strftime("%c")} | <span id="subject"> ${message.subject}</span></a></span> 
     16    % if message.unread: 
     17        <span class="unread"><a href=${h.url_for(controller='messager', action='open',id=message.id) } class="action">${h.msg.get_from(message)} | ${message.date.strftime("%c")} | <span id="subject"> ${message.subject}</span></a></span> 
     18    %else: 
     19        <span><a href=${h.url_for(controller='messager', action='open',id=message.id) } class="action">${h.msg.get_from(message)} | ${message.date.strftime("%c")} | <span id="subject"> ${message.subject}</span></a></span> 
     20    % endif 
    1621% endif 
    17     <a href=${h.url_for(controller='messager', action='delete',id=message.id) } class="action">[Delete]</a> 
    1822</div> 
    1923<br/> 
  • trunk/loreality/loreality/templates/derived/page/mission.html

    r2106 r2111  
    88%endif 
    99</h2> 
    10 % for f in c.misfields: 
     10% for f in c.formfields: 
    1111<h3>${f.t_name.capitalize()}</h3> 
    1212    <p>${getattr(c.mission, f.name)}</p> 
  • trunk/loreality/setup.cfg

    r2097 r2111  
    33tag_svn_revision = true 
    44 
    5 [easy_install] 
    6 find_links = http://www.pylonshq.com/download/ 
     5#[easy_install] 
     6#find_links = http://www.pylonshq.com/download/ 
    77 
    88[nosetests] 
Note: See TracChangeset for help on using the changeset viewer.