Example #1
0
    def post(self):
        if self.user.state == UserState.SHOW_PROFILE:
            selected_users = list(User.by_profile_uuids(self.user.selected_profile_uuids))
            other_user = selected_users[0]

            proposal = Proposal(parent=self.user.key, to_user=other_user.key)
            proposal.put()

            self.user.set_state(UserState.PROPOSED)
            self.user.put()
        else:
            self.abort(400)
Example #2
0
    def get(self):
        state = self.user.state

        if not self.user.verified:
            self.write('Account Not Authorized')

        elif not self.user.has_personal_info():
            self.session.add_flash(u'먼저 기본정보를 작성해 주세요.', level='info')
            self.redirect('/account')

        elif not self.user.has_profile():
            self.session.add_flash(u'먼저 프로필을 작성해 주세요.', level='info')
            self.redirect('/profile')

        elif state == UserState.SHOW_ALL:
            recent_users = User.get_recent_users()
            other_users = filter(lambda u: u.username != self.user.username, recent_users)

            self.render('show_all.html', other_users=other_users)

        elif state == UserState.SHOW_SUMMARY:
            selected_users = list(User.by_profile_uuids(self.user.selected_profile_uuids))

            for user in selected_users:
                user.profile_lines = user.get_random_profile_lines()

            self.render('show_summary.html', selected_users=selected_users)

        elif state == UserState.SHOW_PROFILE:
            other_user = self.user.get_selected_user()

            if other_user:
                self.render('show_profile.html', other_user=other_user)
            else:
                self.write('profile has changed')

        elif state == UserState.PROPOSED:
            proposal = self.user.get_proposal()

            if proposal:
                self.render('show_profile.html', other_user=proposal.to_user.get(),
                                                 comments=proposal.get_comments(),
                                                 proposal_key_str=proposal.key.urlsafe())
            else:
                self.write('no proposal exists')

        else:
            self.abort(400)