Example #1
0
    def post(self):
        step_template = jinjaEnv.get_template("newStep.html")
        self.response.write(step_template.render())

        tStory = Story(title=self.request.get("adventure_name"))
        print("THE TITLE OF THE STORY IS" + tStory.title)
        tStory.put()
Example #2
0
    def post(self):
        import os, static, hashlib
        from models import StoryAuthor, Story, StoryDocument
        from django.template.defaultfilters import slugify
        from google.appengine.runtime.apiproxy_errors import RequestTooLargeError
        
        title = self.request.get('title')
        content = self.request.get('content')
        full_name = self.request.get('full_name')
        mobile_number = self.request.get('mobile_number')
        email = self.request.get('email')

        author = StoryAuthor(full_name=full_name, email=email, mobile_number=mobile_number)
        author.put()
    
        story = Story(title=title)
        if content:
            story.content = content
        story.author = author
        story.put()

        try:
            request_document = self.request.get('document')
            if request_document:
                document_file = self.request.POST['document']        
                document_body = document_file.value
                document_digest = hashlib.sha1(document_body).hexdigest()
                split_name = os.path.splitext(os.path.basename(document_file.filename))
                filename = slugify(split_name[0]) or document_digest
                document_name = filename + split_name[1]
        
                document_path = '/story/%d/document/%s/%s' % (story.key().id(), document_digest, document_name)
                logging.info(document_path)
                story_document = StoryDocument(story=story, path=document_path, name=document_name)
                story_document.put()
                document = static.set(document_path, document_body, document_file.type, name=document_name)
                self.render_to_response("thanks/story.html", document=story_document, story=story)
            else:
                self.render_to_response("thanks/story.html", story=story)
                
        except RequestTooLargeError, message:
            from api_preferences import facebook as fb_prefs, google_friend_connect as gfc
            self.render_to_response("start.html",
                                       FACEBOOK_API_KEY=fb_prefs.get('api_key'),
                                       FACEBOOK_CROSS_DOMAIN_RECEIVER_URL=fb_prefs.get('cross_domain_receiver_url'),
                                       GOOGLE_FRIEND_CONNECT_SITE_ID=gfc.get('site_id'),
                                       request_too_large_error=True,
                                       title=title,
                                       content=content,
                                       full_name=full_name,
                                       email=email,
                                       mobile_number=mobile_number)
Example #3
0
    def _create_new_story(self, event):
        logging.info('Creating story')
        story = Story(story_id=event.story_id, name=event.story_title)
        story.put()

        project = Project.get()

        api_url = 'http://www.pivotaltracker.com/services/v3/projects/{PROJECT_ID}/stories/{STORY_ID}/notes'.replace('{PROJECT_ID}', project.project_id).replace('{STORY_ID}', story.story_id)
        comment_xml = '<note><text>http://{APP_ID}.appspot.com/s/{STORY_ID}</text></note>'.replace('{APP_ID}', os.environ['APPLICATION_ID']).replace('{STORY_ID}', story.story_id)

        logging.info('Api url: ' + api_url)
        logging.info('Comment xml: ' + comment_xml)

        #post a comment back to pivotal tracker
        result = urlfetch.fetch(url=api_url,
                                payload=comment_xml,
                                method=urlfetch.POST,
                                headers={'Content-Type': 'application/xml', 'X-TrackerToken': project.api_token})
        logging.info('Result of API call: ' + result.content)
Example #4
0
    def get(self, story_id):

        story = Story.get_by_story_id(story_id)

        if story is None:
            logging.info('creating story ' + story_id)
            story = Story(story_id=story_id, user = users.get_current_user(), name=story_id)
            story.put()

        story_lines = story.story_lines()

        java_days = story.actual_java_days()
        cs_days = story.actual_cs_days()

        appengineutils.render_template(self.response, 'story_history.html', {'story_lines': story_lines,
                                                                'dates': last_five_days(),
                                                                'java_days': java_days,
                                                                'cs_days': cs_days,
                                                                'story': story})
Example #5
0
    def post(self):

        rStory = Story(title=self.request.get("adventure_name"))
        rStory.put()

        storypoint1 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("first_story_point"))
        storypoint2 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceA_story_point"))
        storypoint3 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceB_story_point"))
        storypoint4 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceC_story_point"))
        storypoint5 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceD_story_point"))
        storypoint6 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceE_story_point"))
        storypoint7 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceF_story_point"))
        storypoint8 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceG_story_point"))
        storypoint9 = StoryPoint(story_key=rStory.key,
                                 text=self.request.get("choiceH_story_point"))
        storypoint10 = StoryPoint(story_key=rStory.key,
                                  text=self.request.get("choiceI_story_point"))
        storypoint11 = StoryPoint(story_key=rStory.key,
                                  text=self.request.get("choiceJ_story_point"))
        storypoint12 = StoryPoint(story_key=rStory.key,
                                  text=self.request.get("choiceK_story_point"))
        storypoint13 = StoryPoint(story_key=rStory.key,
                                  text=self.request.get("choiceL_story_point"))

        storypoint1.put()
        storypoint2.put()
        storypoint3.put()
        storypoint4.put()
        storypoint5.put()
        storypoint6.put()
        storypoint7.put()
        storypoint8.put()
        storypoint9.put()
        storypoint10.put()
        storypoint11.put()
        storypoint12.put()
        storypoint13.put()

        rStory.first_story_point_key = storypoint1.key

        rStory.put()

        choicepoint1 = ChoicePoint(begin_story_point_key=storypoint1.key,
                                   end_story_point_key=storypoint2.key,
                                   text=self.request.get("Choice_A"))
        choicepoint2 = ChoicePoint(begin_story_point_key=storypoint1.key,
                                   end_story_point_key=storypoint3.key,
                                   text=self.request.get("Choice_B"))
        choicepoint3 = ChoicePoint(begin_story_point_key=storypoint2.key,
                                   end_story_point_key=storypoint4.key,
                                   text=self.request.get("Choice_C"))
        choicepoint4 = ChoicePoint(begin_story_point_key=storypoint2.key,
                                   end_story_point_key=storypoint5.key,
                                   text=self.request.get("Choice_D"))
        choicepoint5 = ChoicePoint(begin_story_point_key=storypoint3.key,
                                   end_story_point_key=storypoint6.key,
                                   text=self.request.get("Choice_E"))
        choicepoint6 = ChoicePoint(begin_story_point_key=storypoint3.key,
                                   end_story_point_key=storypoint7.key,
                                   text=self.request.get("Choice_F"))
        choicepoint7 = ChoicePoint(begin_story_point_key=storypoint4.key,
                                   end_story_point_key=storypoint8.key,
                                   text=self.request.get("Choice_G"))
        choicepoint8 = ChoicePoint(begin_story_point_key=storypoint4.key,
                                   end_story_point_key=storypoint9.key,
                                   text=self.request.get("Choice_H"))
        choicepoint9 = ChoicePoint(begin_story_point_key=storypoint6.key,
                                   end_story_point_key=storypoint10.key,
                                   text=self.request.get("Choice_I"))
        choicepoint10 = ChoicePoint(begin_story_point_key=storypoint6.key,
                                    end_story_point_key=storypoint11.key,
                                    text=self.request.get("Choice_J"))
        choicepoint11 = ChoicePoint(begin_story_point_key=storypoint7.key,
                                    end_story_point_key=storypoint12.key,
                                    text=self.request.get("Choice_K"))
        choicepoint12 = ChoicePoint(begin_story_point_key=storypoint7.key,
                                    end_story_point_key=storypoint13.key,
                                    text=self.request.get("Choice_L"))

        rStory.put()

        storypoint1.put()
        storypoint2.put()
        storypoint3.put()
        storypoint4.put()
        storypoint5.put()
        storypoint6.put()
        storypoint7.put()
        storypoint8.put()
        storypoint9.put()
        storypoint10.put()
        storypoint11.put()
        storypoint12.put()
        storypoint13.put()

        choicepoint1.put()
        choicepoint2.put()
        choicepoint3.put()
        choicepoint4.put()
        choicepoint5.put()
        choicepoint6.put()
        choicepoint7.put()
        choicepoint8.put()
        choicepoint9.put()
        choicepoint10.put()
        choicepoint11.put()
        choicepoint12.put()

        display_dictionary = {
            "display_title": rStory.title,
            "display_sp_1": storypoint1.text,
            "display_sp_2": storypoint2.text,
            "display_sp_3": storypoint3.text,
            "display_sp_4": storypoint4.text,
            "display_sp_5": storypoint5.text,
            "display_sp_6": storypoint6.text,
            "display_sp_7": storypoint7.text,
            "display_sp_8": storypoint8.text,
            "display_sp_9": storypoint9.text,
            "display_sp_10": storypoint10.text,
            "display_sp_11": storypoint11.text,
            "display_sp_12": storypoint12.text,
            "display_sp_13": storypoint13.text,
            "display_cp_1": choicepoint1.text,
            "cp1_next_key": choicepoint1.end_story_point_key.id(),
            "display_cp_2": choicepoint2.text,
            "cp2_next_key": choicepoint2.end_story_point_key.id(),
            "display_cp_3": choicepoint3.text,
            "display_cp_4": choicepoint4.text,
            "display_cp_5": choicepoint5.text,
            "display_cp_6": choicepoint6.text,
            "display_cp_7": choicepoint7.text,
            "display_cp_8": choicepoint8.text,
            "display_cp_9": choicepoint9.text,
            "display_cp_10": choicepoint10.text,
            "display_cp_11": choicepoint11.text,
            "display_cp_12": choicepoint12.text,
        }

        result_template = jinjaEnv.get_template("result.html")
        #self.response.write(result_template.render())
        self.response.write(result_template.render(display_dictionary))