Changeset 1389


Ignore:
Timestamp:
02/21/07 15:20:19 (12 years ago)
Author:
jukka
Message:

Closed #1146, changed front page to use collections instead of stories. Other fixes here and there.

Location:
trunk
Files:
2 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Collection.py

    r1387 r1389  
    2929 
    3030from config import PROJECTNAME, ALL_CONTENT_TYPES, CONTENT_TYPES, DEFAULT_ICONS, ACTIVITY_TYPES, TOOLS_TYPES 
    31 from Resources import CommonMixIn 
     31from Resources import Resource 
    3232from permissions import MODIFY_CONTENT 
    3333 
     
    3737        accessor='Description', 
    3838        widget=TextAreaWidget( 
    39             label="Learning story", 
     39            label="Learning and teaching story", 
    4040            description="", 
    4141            label_msgid='label_learning_story', 
     
    124124            visible = {'edit' : 'invisible', 'view' : 'invisible' } 
    125125            ) 
     126        ), 
     127    ComputedField('goodStory', 
     128        index = 'FieldIndex', 
     129        expression = 'here.isThisGoodStory()', 
     130        isMetadata = True 
    126131        ) 
    127132)) 
     
    129134schema = schema.copy() 
    130135 
    131 class Collection(BaseContent,CommonMixIn): 
     136class Collection(Resource): 
    132137    """Collection""" 
    133138     
     
    230235        field.set(self, new_value, collection_position=self.getLargestCount(reftype)) 
    231236 
     237    def isThisGoodStory(self): 
     238        """ Check if there is content,method,tool and description """         
     239        desc=self.Description() 
     240        c=self.getRelatedContent() 
     241        m=self.getRelatedMethods() 
     242        t=self.getRelatedTools() 
     243        wtool=getToolByName(self, 'portal_workflow') 
     244        r= wtool.getInfoFor(self,'review_state',None)!='deleted' 
     245        if desc and c and m and t and r: 
     246            return True 
     247        else: 
     248            return False 
     249 
    232250    def getItemCount(self): 
    233251        """ return how many items are in collection """ 
     
    250268        arr.sort() 
    251269        return arr 
     270 
     271    def getBlurp(self): 
     272        """ Some 1000 chars or something FIXME TO FIND NICE PLACES TO CUT (<p><br> etc.)""" 
     273        return self.Description()[:200] 
    252274 
    253275    def getResources(self, reftype='relatedContent'): 
     
    405427            else: 
    406428                reftype='keeper' 
    407             if reftype==keeper: 
     429 
     430            if reftype=='keeper': 
    408431                newlist.append(o.UID()) 
    409432            else: 
  • trunk/Extensions/Install.py

    r1387 r1389  
    778778            # Remove unnecessary topic - it will be replaced with a properly named one 
    779779            folder._delObject('activities') 
    780  
     780            print >>out, "Migration from 1.7 complete"             
     781        if old<="1.7.1": 
     782            print >>out, "Starting migration from 1.7.1" 
    781783            print >>out, "Split existing collections to refer resources/methods/tools separately" 
    782             # Get collections folder and run cleaning script 
     784            # Get collections folder and run cleaning script         
    783785            for member in self.community.objectValues('MemberFolder'): 
    784786                if hasattr(member.aq_base, 'collections'): 
    785787                    for c in member.collections.objectValues('Collection'): 
    786788                        c.cleanRefsToResources() 
    787             print >>out, "Migration from 1.7 complete"             
     789            print >>out, "Migration from 1.7.1 complete"             
    788790 
    789791 
  • trunk/LeMillTool.py

    r1379 r1389  
    186186        return stri 
    187187 
    188     def getStoryCandidate(self, only_with_story=False): 
     188    def getStoryCandidate(self, only_with_story=True): 
    189189        """ Random pick for one content, method and tool or story if only_with_story """ 
    190190        pc=getToolByName(self, 'portal_catalog') 
    191         if GOOD_STORIES_ONLY or only_with_story: 
    192             stories=pc({'portal_type':'Story', 'review_state':'public'}) 
     191        if GOOD_STORIES_ONLY and only_with_story: 
     192            stories=pc({'getGoodStory':True}) 
     193            if not stories: 
     194                return self.getStoryCandidate(only_with_story=False) 
    193195            story=choice(stories) 
    194196            story=story.getObject() 
    195197            content=story.getRelatedContent() 
    196             method=story.getRelatedActivities() 
     198            method=story.getRelatedMethods() 
    197199            tool=story.getRelatedTools() 
    198200            if content: 
  • trunk/PresentationMaterial.py

    r1321 r1389  
    2424from Products.CMFCore.utils import getToolByName 
    2525from Piece import Piece 
    26  
    2726from config import PROJECTNAME, MODIFY_CONTENT, VIEW, MIMETYPE_WHITELIST 
    2827from FieldsWidgets import * 
  • trunk/config.py

    r1385 r1389  
    306306 
    307307# Front-page shows only resources that already have stories, no random combinations. 
    308 GOOD_STORIES_ONLY = False 
     308GOOD_STORIES_ONLY = True 
  • trunk/skins/lemill/collection_view.cpt

    r1387 r1389  
    3434        <h1 i18n:translate="collection_title">Collection: <span i18n:name="title" tal:replace="here/Title"/></h1> 
    3535 
    36         <h2 i18n:translate="label_learning_story">Learning story</h2>  
     36        <h2 i18n:translate="label_learning_story">Learning and teaching story</h2>  
    3737        <div tal:condition="here/Description" tal:replace="structure here/Description" /> 
    38         <p tal:condition="not:here/Description" i18n:translate="learning_story_explanation">You have not written a learning story about this collection yet. 
     38        <p tal:condition="not:here/Description" i18n:translate="learning_story_explanation">You have not written a story about this collection yet. 
    3939If you have used these resources in a learning session you can share 
    40 your experiences by <a href="edit">writing a learning story</a>.</p> 
     40your experiences by <a href="edit">writing a learning and teaching story</a>.</p> 
    4141 
    4242    <tal:content condition="here/getRelatedContent" tal:define="resources python:here.getResources(reftype='relatedContent');"> 
  • trunk/skins/lemill/front-page.pt

    r1387 r1389  
    6868        </table> 
    6969 
    70     <h2><b i18n:translate="heading_learning_story">Learning story</b><b tal:condition="story" tal:omit-tag="">:</b> <span tal:condition="story" tal:content="story/title" /></h2> 
     70    <h2><b i18n:translate="heading_learning_story">Learning and teaching story</b><b tal:condition="story" tal:omit-tag="">:</b> <span tal:condition="story" tal:content="story/title" /></h2> 
    7171 
    7272    <div tal:condition="story">     
     
    7575    </div> 
    7676    <div tal:condition="not:story"> 
    77     <p i18n:translate="no_story_explanation">Nobody has written a learning story about using these resources. Now it is your time to contribute.</p> 
     77    <p i18n:translate="no_story_explanation">Nobody has written a story about using these resources. Now it is your time to contribute.</p> 
    7878    </div> 
    7979    <tal:no_empties condition="python: story_candidate['chcontent'] and story_candidate['method'] and story_candidate['tool']"> 
    80     <h2><a href="new_story" tal:attributes="href python:test(isAnon, 'join_form', '%s/%s/stories/new_story?chcontent=%s&amp;method=%s&amp;tool=%s' % (membersfolder.absolute_url(), member, story_candidate['chcontent'].UID(), story_candidate['method'].UID(), story_candidate['tool'].UID()))" i18n="write_your_learning_story">Write your learning story</a> <span i18n:translate="about_using_these_resources">about using these resources...</span></h2>  
     80    <h2><a href="new_story" tal:attributes="href python:test(isAnon, 'join_form', '%s/%s/stories/new_story?chcontent=%s&amp;method=%s&amp;tool=%s' % (membersfolder.absolute_url(), member, story_candidate['chcontent'].UID(), story_candidate['method'].UID(), story_candidate['tool'].UID()))" i18n="write_your_learning_story">Write your learning and teaching story</a> <span i18n:translate="about_using_these_resources">about using these resources...</span></h2>  
    8181    </tal:no_empties> 
    8282 
  • trunk/skins/lemill/new_story.py

    r1375 r1389  
    1919    home = mtool.getHomeFolder() 
    2020 
    21 stories = home.getStoriesFolder() 
     21collections = home.getCollectionsFolder() 
    2222 
    23 new_id = context.generateUniqueId('Story') 
    24 new_ob_id = stories.invokeFactory(id=new_id, type_name='Story') 
     23new_id = context.generateUniqueId('Collection') 
     24new_ob_id = collections.invokeFactory(id=new_id, type_name='Collection') 
    2525 
    26 obj = getattr(stories.portal_factory, new_ob_id, None) 
     26obj = getattr(collections.portal_factory, new_ob_id, None) 
    2727if not obj: 
    2828    raise 'ops' 
     
    4545    refs_to_tools.append(tool)     
    4646 
    47 obj.setRelatedActivities(refs_to_methods) 
     47obj.setRelatedMethods(refs_to_methods) 
    4848obj.setRelatedTools(refs_to_tools) 
    4949obj.setRelatedContent(refs_to_content) 
     
    5252    return new_id 
    5353else: 
    54     return context.REQUEST.RESPONSE.redirect(obj.absolute_url()+'/story_edit') 
     54    return context.REQUEST.RESPONSE.redirect(obj.absolute_url()+'/collection_edit') 
  • trunk/skins/lemill/portlet_collection_actions.pt

    r1387 r1389  
    55<div metal:define-macro="portlet" id="portlet-material-actions"> 
    66 
     7<div metal:use-macro="here/portlet_member/macros/memberportrait" /> 
     8 
    79<div class="tb-portlet" metal:define-macro="edit_div" tal:condition="context/amIOwner"> 
    810    <ul> 
    911        <li> 
    10             <a href="" tal:attributes="href string:${context/absolute_url}/edit"><tal:block i18n:translate="label_edit_collection">Edit collection</tal:block>...</a> 
     12            <a href="" tal:attributes="href string:${context/absolute_url}/collection_edit"><tal:block i18n:translate="label_edit_collection">Edit collection</tal:block>...</a> 
    1113        </li> 
    1214        <li> 
  • trunk/version.txt

    r1385 r1389  
    1 1.7.1 
     11.7.2 
Note: See TracChangeset for help on using the changeset viewer.