Changeset 1370


Ignore:
Timestamp:
02/14/07 02:03:14 (13 years ago)
Author:
jukka
Message:

Worked on #1146. Search for suitable existing story is done and stories can be written. Must find out why portal_factory decides to keep stories, if user cancels or wanders off from story creation. Also the search for existing stories is tricky. Current way isn't fast, but I don't know if it can be done any faster -- and it's our front page, will get lots of hits.

Well, one way would be to combine stories' uids to one superuid and try to match that. We'll see..

Location:
trunk
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/FieldsWidgets.py

    r1346 r1370  
    325325        'helper_js' : ('js_helpers.js',), 
    326326    }) 
    327  
    328327 
    329328class ChapterWidget(SelectionWidget): 
  • trunk/LeMillTool.py

    r1366 r1370  
    195195        if content and method and tool: 
    196196            story=None 
    197         #    stories=self.reference_catalog({'relationship':'relatedContent', 'targetUID':content.UID()}) 
    198         #    stories=[x for x in stories if x.targetUID==content.UID() 
     197            relations_to_this_content=rc({'relationship':'relatesToContent', 'targetUID':content.UID()}) 
     198            stories=[x.sourceUID for x in relations_to_this_content] 
     199            good_stories=[] 
     200            for storc in stories: 
     201                if rc({'sourceUID':storc, 'relationship':'relatesToMethods', 'targetUID':method.UID()}) and rc({'sourceUID':storc, 'relationship':'relatesToTools', 'targetUID':tool.UID()}): 
     202                    good_stories.append(storc) 
     203            if good_stories: 
     204                story=choice(good_stories) 
     205                story=self.uid_catalog(UID=story)[0].getObject() 
     206              
    199207        else: 
    200208            story=None 
  • trunk/Story.py

    r1264 r1370  
    4444 
    4545    ReferenceField('relatedContent', 
    46         relationship = 'relatesTo', 
     46        relationship = 'relatesToContent', 
    4747        multiValued = True, 
    4848        isMetadata = True, 
     
    6666            ) 
    6767        ), 
    68     ReferenceField('relatedActivities', 
    69         relationship = 'relatesToActivities', 
     68    ReferenceField('relatedMethods', 
     69        relationship = 'relatesToMethods', 
    7070        multiValued = True, 
    7171        isMetadata = True, 
     
    8282            size = 4, 
    8383            i18n_domain = "lemill", 
    84             label = "Related Activities", 
    85             label_msgid = "label_related_activities", 
     84            label = "Related Methods", 
     85            label_msgid = "label_related_methods", 
    8686            description = "", 
    87             description_msgid = "help_story_related_activities", 
     87            description_msgid = "help_story_related_methods", 
    8888            visible = {'edit' : 'invisible', 'view' : 'invisible' } 
    8989            ) 
     
    143143    security.declareObjectPublic() 
    144144 
    145 #FIXME: Should this be a method of the Story class? Right now it's a function of the Story module. --tarmo 
    146 def getHasCoverImage(self): 
    147     """ this gets asked often """ 
    148     return False 
     145    def getHasCoverImage(self): 
     146        """ this gets asked often """ 
     147        return False 
    149148 
     149    def getBlurp(self): 
     150        """ Some 1000 chars or something FIXME TO FIND NICE PLACES TO CUT (<p><br> etc.)""" 
     151        return self.getBodyText()[:200] 
    150152 
    151153registerType(Story, PROJECTNAME) 
  • trunk/skins/lemill/front-page.pt

    r1368 r1370  
     1 
    12<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 
    23      lang="en" 
     
    67 
    78<div metal:fill-slot="main" style="width:100%" tal:define="story_candidate python:here.lemill_tool.getStoryCandidate(); 
    8 story python:story_candidate['story'];"> 
     9story python:story_candidate['story']; 
     10null python:here.REQUEST.set('chcontent',story_candidate['chcontent'].UID()); 
     11null python:here.REQUEST.set('method',story_candidate['method'].UID()); 
     12null python:here.REQUEST.set('tool',story_candidate['tool'].UID());"> 
    913 
    1014<table border="0" cellpadding="0" cellspacing="0" width="780"> 
     
    7781    </div> 
    7882    <tal:no_empties condition="python: story_candidate['chcontent'] and story_candidate['method'] and story_candidate['tool']"> 
    79     <h2><a href="new_story" tal:attributes="href python:'new_story?content=%s&method=%s&tool=%s' % (story_candidate['chcontent'].absolute_url(), story_candidate['method'].absolute_url(), story_candidate['tool'].absolute_url())" i18n="write_your_learning_story">Write your learning story</a> <span i18n:translate="about_using_these_resources">about using these resources...</span></h2>  
     83    <h2><a href="new_story" tal:attributes="href python:test(isAnon, 'join_form', '%s/%s/stories/new_story?chcontent=%s&method=%s&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>  
    8084    </tal:no_empties> 
    8185 
     
    8791</html> 
    8892 
     93 
  • trunk/skins/lemill/story_edit.cpt

    r473 r1370  
    7676    <metal:fill fill-slot="main"> 
    7777      <metal:main define-macro="main"> 
    78         <h1 tal:content="title_string | here/title_or_id" /> 
     78        <h1><span tal:condition="not:here/title" i18n:translate="write_a_story">Write a learning story</span><span tal:omit-tag="" tal:condition="here/title" tal:content="here/title"/> </h1> 
    7979        <metal:use_typedescription use-macro="typedescription_macro" /> 
     80 
     81        <table width="504" border="0" cellpadding="0" cellspacing="8"  
     82          tal:define="chcontent python:context.getRelatedContent(); 
     83              method python:context.getRelatedMethods(); 
     84              tool python:context.getRelatedTools();"> 
     85            <tr> 
     86                <td width="160" class="content_coverimage_cell"> 
     87                <tal:not_empty tal:condition="chcontent"> 
     88                    <a href="#" tal:define="chcontent python:chcontent[0]" tal:attributes="href string:${chcontent/absolute_url}/view"> 
     89                    <img tal:attributes="src chcontent/coverImage/absolute_url | string:images/default_learningresource.png; 
     90                                        alt chcontent/Title | nothing;" src="images/default_learningresource.png" alt="Cover image" /> 
     91                </a> 
     92                </tal:not_empty> 
     93                </td> 
     94                <td width="160" class="method_coverimage_cell" > 
     95                <tal:not_empty tal:condition="method"> 
     96                <a href="#" tal:define="method python:method[0]"  tal:attributes="href method/absolute_url | nothing"> 
     97                    <img tal:attributes="src method/coverImage/absolute_url | string: images/default_method.png; 
     98                                        alt method/Title | nothing;" src="images/default_method.png" alt="Cover image" /> 
     99                </a> 
     100                </tal:not_empty> 
     101                </td> 
     102                <td width="160" class="tool_coverimage_cell" > 
     103                <tal:not_empty tal:condition="tool"> 
     104                <a href="#" tal:define="tool python:tool[0]"  tal:attributes="href tool/absolute_url | nothing"> 
     105                    <img tal:attributes="src tool/coverImage/absolute_url | string: images/default_tool.png; 
     106                                        alt tool/Title | nothing;" src="images/default_tool.png" alt="Cover image" /> 
     107                </a> 
     108                </tal:not_empty> 
     109                </td> 
     110 
     111            </tr> 
     112            <tr> 
     113                <td class="content_label_cell"> 
     114                    <tal:not_empty tal:condition="chcontent"> 
     115                        <a href="#" tal:define="chcontent python:chcontent[0]" tal:attributes="href string:${chcontent/absolute_url}/view" tal:content="chcontent/title_or_id" /> 
     116                    </tal:not_empty> 
     117                </td> 
     118                <td class="method_label_cell"> 
     119                    <tal:not_empty tal:condition="method"> 
     120                    <a href="#" tal:define="method python:method[0]"  tal:attributes="href method/absolute_url | nothing" tal:content="method/title_or_id" /> 
     121                    </tal:not_empty> 
     122                </td> 
     123                <td class="tool_label_cell"> 
     124                    <tal:not_empty tal:condition="tool"> 
     125                    <a href="#" tal:define="tool python:tool[0]"  tal:attributes="href tool/absolute_url | nothing" tal:content="tool/title_or_id" /> 
     126                    </tal:not_empty> 
     127                </td> 
     128            </tr> 
     129 
     130        </table> 
     131         
    80132        <metal:use_body use-macro="body_macro" /> 
    81133        <metal:use_footer use-macro="footer_macro" /> 
Note: See TracChangeset for help on using the changeset viewer.