Changeset 3029 for trunk


Ignore:
Timestamp:
05/10/10 17:29:46 (10 years ago)
Author:
jukka
Message:

Fixed #1962. Refactored messages that are based on properties of resources (deleted, draft, private, missing language) to come from a single source, getMessages-method and message_macros.pt. It should be easy to expand to add new suggestions.

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/CommonMixIn.py

    r3026 r3029  
    189189        actual_path=list(self.getPhysicalPath()) 
    190190        return default_path==actual_path or (actual_path[-2]=='trash' and self.getState()=='deleted') 
     191 
     192    def getMessages(self): 
     193        """ Returns permanent messages related to this resource (draft, is missing a language etc.) """ 
     194        messages=[] 
     195        if self.isDeleted(): 
     196            messages.append('deleted') 
     197        return messages 
    191198 
    192199 
  • trunk/LearningResource.py

    r3014 r3029  
    4444    security = ClassSecurityInfo() 
    4545    allow_discussion = True 
     46 
     47    ################ Messages ################################################# 
     48 
     49    def getMessages(self): 
     50        """ Returns permanent messages related to this resource (draft, is missing a language etc.) """ 
     51        messages=Resource.getMessages(self) 
     52        if self.isDraft(): 
     53            messages.append('draft') 
     54        if self.isPrivate(): 
     55            messages.append('private') 
     56        return messages 
     57 
    4658 
    4759    ################ After add/edit ################################################# 
     
    355367                score += 10 
    356368        # +1 if assigned to group 
    357         group_editing = getattr(self, 'getGroupEditing', None) 
     369        group_editing = hasattr(self, 'getGroupEditing') 
    358370        if group_editing: 
    359371            if self.getGroupEditing(): 
  • trunk/Piece.py

    r2975 r3029  
    147147 
    148148 
     149    def getMessages(self): 
     150        """ Instead of inheriting from Resource, this should inherit from CommonMixIn to not worry about language """ 
     151        messages=CommonMixIn.getMessages(self) 
     152        return messages 
     153 
     154 
    149155    # at_post_edit_script from Resources without recalculateAuthor 
    150156    security.declarePrivate('at_post_edit_script') 
  • trunk/Resource.py

    r3026 r3029  
    5252 
    5353 
     54 
     55 
     56    ################ Messages ################################################# 
     57 
     58    def getMessages(self): 
     59        """ Returns permanent messages related to this resource (draft, is missing a language etc.) """ 
     60        messages=CommonMixIn.getMessages(self) 
     61        if (not messages) and (not self.Language()) and self.canIEdit(): 
     62            messages.append('language_missing') 
     63        if self.REQUEST.has_key('version'): 
     64            messages=['old_version'] # overwrite other messages, this has the priority 
     65        return messages 
    5466 
    5567 
     
    10181030 
    10191031 
     1032    ############# Additional editing ###################################### 
     1033     
     1034    security.declareProtected(MODIFY_CONTENT, 'updateLanguage') 
     1035    def updateLanguage(self,lang): 
     1036        """ Just change language, called from javascript """ 
     1037        self.setLanguage(lang) 
     1038        self.at_post_edit_script() 
     1039        lt=getToolByName(self, 'lemill_tool') 
     1040        lt.addPortalMessage(_('Thank you!')) 
     1041        return self.REQUEST.RESPONSE.redirect(self.absolute_url()+'/base_view') 
     1042 
    10201043InitializeClass(Resource) 
  • trunk/skins/lemill/base_view.pt

    r2873 r3029  
    1919            body_macro view_macros/body | body_macro | base_macros/body; 
    2020            errors python:request.get('errors', {}); 
    21             body_macro python:test(here.isDeleted(), path('here/document_byline/macros/deletionnote'),body_macro); 
    22             body_macro python:test(here.getState()=='private' and (memberid!=here.Creator() and not here.amIManager()), path('here/document_byline/macros/privatenote'),body_macro); 
    23             showOldVersionMessage here/REQUEST/version|nothing; 
     21            body_macro python:test(here.isDeleted() or (here.getState()=='private' and (memberid!=here.Creator() and not here.amIManager())), path('here/document_byline/macros/empty'),body_macro); 
    2422            "> 
    2523        <metal:header define-slot="header"><div metal:use-macro="here/collection_navigation/macros/collection_navigation"/> 
    26         <h1><span tal:replace="title_string | here/title_or_id" /><span i18n:domain="lemill" i18n:translate="text_deleted_heading" tal:condition="here/isDeleted">(DELETED)</span></h1> 
    27         <div metal:use-macro="here/document_byline/macros/byline" /> 
    28         <metal:draft define-macro="draft"><div tal:condition="here/isDraft | nothing" class="portalMessage" i18n:domain="lemill" i18n:translate="text_draft_status"> 
    29                 This learning resource is in draft status. 
    30         </div></metal:draft><tal:ifoldversion condition="showOldVersionMessage"> 
    31             <div class="portalMessage" i18n:domain="lemill" i18n:translate="text_old_history_version"> 
    32                 You are viewing old version from <span i18n:name="thetime" tal:define="old_version_time python: here.getTimeForOldHistory(showOldVersionMessage)"  tal:content="python:DateTime(old_version_time).strftime('%d.%m.%Y %H:%M:%S')">Fri Oct 27 04:49:26 2006</span>. 
    33             </div> 
    34         </tal:ifoldversion></metal:header>                                                                 
     24            <h1><span tal:replace="title_string | here/title_or_id" /><span i18n:domain="lemill" i18n:translate="text_deleted_heading" tal:condition="here/isDeleted">(DELETED)</span></h1> 
     25            <div metal:use-macro="here/document_byline/macros/byline" /> 
     26            <tal:messages repeat="message here/getMessages"> 
     27                <div metal:use-macro="python:path('here/macros_messages/macros/'+message)" /> 
     28            </tal:messages> 
     29        </metal:header>                                                                 
    3530        <metal:use_body use-macro="body_macro" />         
    3631        <metal:footer define-slot="footer">         
  • trunk/skins/lemill/document_byline.pt

    r2873 r3029  
    4040</span></div> 
    4141 
     42used to replace content in deleted or private pages: 
    4243 
    43 <div metal:define-macro="deletionnote" 
    44      i18n:domain="lemill" 
    45      tal:define="note_text context/getDeletionReason | None"> 
    46  
    47 <tal:isthereareason condition="note_text"> 
    48 <h3 i18n:translate="heading_reason_for_deletion">Reason for deletion:</h3>  
    49 <p tal:content="note_text">Because ...</p> 
    50 </tal:isthereareason> 
    51  
    52 </div> 
    53  
    54 <div metal:define-macro="privatenote" class="portalMessage" 
    55      i18n:domain="lemill"> 
    56 <h3 i18n:translate="text_resource_is_private">This resource is private and visible only for its author.</h3> 
    57 </div> 
     44<metal:empty define-macro="empty"> 
     45</metal:empty> 
    5846 
    5947<div metal:define-macro="copyright"> 
Note: See TracChangeset for help on using the changeset viewer.