コード例 #1
0
ファイル: support.py プロジェクト: SecondFriend/second-friend
    def get(self):

        # keep non-admin users away
        if not users.is_current_user_admin():
            self.redirect("/")

        # if user is an admin
        # render support page
        if users.is_current_user_admin():

            # get counselor, if new, then insert
            counselor = Counselor.get_or_insert(str(users.get_current_user().user_id()))

            # set default counselor name to user's nickname
            if not counselor.name:
                counselor.name = users.get_current_user().nickname()

            # update user status to 1 - ready for work!
            counselor.status = 1
            counselor.put()

            template_vars = {
                "app_name": settings.APP_NAME,
                "counselor": counselor,
                "logout_url": "/logout",
                "where": "Support",
            }

            self._output_template("support.html", **template_vars)
コード例 #2
0
ファイル: support.py プロジェクト: SecondFriend/second-friend
    def get(self):

        # keep non-admin users away
        if not users.is_current_user_admin():
            self.redirect('/')

        # if user is an admin
        # render support page
        if users.is_current_user_admin():

            # get counselor, if new, then insert
            counselor = Counselor.get_or_insert(
                str(users.get_current_user().user_id()))

            # set default counselor name to user's nickname
            if not counselor.name:
                counselor.name = users.get_current_user().nickname()

            # update user status to 1 - ready for work!
            counselor.status = 1
            counselor.put()

            template_vars = {
                'app_name': settings.APP_NAME,
                'counselor': counselor,
                'logout_url': '/logout',
                'where': 'Support'
            }

            self._output_template('support.html', **template_vars)
コード例 #3
0
    def post(self):
        counselor = Counselor.get_or_insert(str(users.get_current_user().user_id()))

        if self.request.get("avatar"):
            counselor.avatar = db.Blob(images.resize(self.request.get("avatar"), 90, 90))

        counselor.name = self.request.get("name")
        counselor.expertises = self.request.POST.getall("expertises")
        counselor.put()

        self.redirect("/counselor/edit?saved=1")
コード例 #4
0
    def post(self):
        counselor = Counselor.get_or_insert(
            str(users.get_current_user().user_id()))

        if self.request.get('avatar'):
            counselor.avatar = db.Blob(
                images.resize(self.request.get('avatar'), 90, 90))

        counselor.name = self.request.get('name')
        counselor.expertises = self.request.POST.getall('expertises')
        counselor.put()

        self.redirect('/counselor/edit?saved=1')
コード例 #5
0
    def get(self):

        # if user is not logged in yet
        # show the welcome page
        if not users.get_current_user():
            # welcome page
            template_vars = {'where': 'Index', 'login_url': '/login'}
            self._output_template('welcome.html', **template_vars)
            return

        # user is logged in but not an admin
        # show the unauthorized page
        if not users.is_current_user_admin():
            # unauthorized page
            template_vars = {
                'where': 'Administration',
                'email': users.get_current_user().email(),
                'logout_url': '/logout',
            }
            self._output_template('unauthorized.html', **template_vars)
            return

        # user is an admin - redirect to support page
        # render support page
        if users.is_current_user_admin():

            self.redirect('/support')

            # get counselor, if new, then insert
            counselor = Counselor.get_or_insert(
                str(users.get_current_user().user_id()))

            # set default counselor name
            if not counselor.name:
                counselor.name = users.get_current_user().nickname()

            # update user status to 1
            counselor.status = 1
            counselor.put()

            template_vars = {
                'app_name': settings.APP_NAME,
                'counselor': counselor,
                'logout_url': '/logout',
                'where': 'Support'
            }

            self._output_template('support.html', **template_vars)
コード例 #6
0
    def get(self):
        counselor = Counselor.get_or_insert(
            str(users.get_current_user().user_id()))

        # list of expertises
        _expertises = [
            'Cyberbully', 'Child Rights', 'Sexual Abuse', 'Teen Relationship',
            'Drugs', 'School Stress', 'Parenting'
        ]

        template_vars = {
            'saved': self.request.get('saved'),
            'id': str(users.get_current_user().user_id()),
            'counselor': counselor,
            '_expertises': _expertises
        }

        self._output_template('counselor-edit.html', **template_vars)
コード例 #7
0
ファイル: index.py プロジェクト: SecondFriend/second-friend
    def get(self):
        
        # if user is not logged in yet
        # show the welcome page
        if not users.get_current_user():
            # welcome page
            template_vars = {'where': 'Index', 'login_url': '/login'}
            self._output_template('welcome.html', **template_vars)
            return

        # user is logged in but not an admin
        # show the unauthorized page
        if not users.is_current_user_admin():
            # unauthorized page
            template_vars = {'where': 'Administration', 'email': users.get_current_user().email(), 'logout_url': '/logout', }
            self._output_template('unauthorized.html', **template_vars)
            return
            
        # user is an admin - redirect to support page
        # render support page    
        if users.is_current_user_admin():

            self.redirect('/support')

            # get counselor, if new, then insert
            counselor = Counselor.get_or_insert(str(users.get_current_user().user_id()))
        
            # set default counselor name
            if not counselor.name:
                counselor.name = users.get_current_user().nickname()

            # update user status to 1
            counselor.status = 1
            counselor.put()

            template_vars = {
                'app_name': settings.APP_NAME,
                'counselor': counselor,
                'logout_url': '/logout',
                'where': 'Support'
            }

            self._output_template('support.html', **template_vars)
コード例 #8
0
    def get(self):
        counselor = Counselor.get_or_insert(str(users.get_current_user().user_id()))

        # list of expertises
        _expertises = [
            "Cyberbully",
            "Child Rights",
            "Sexual Abuse",
            "Teen Relationship",
            "Drugs",
            "School Stress",
            "Parenting",
        ]

        template_vars = {
            "saved": self.request.get("saved"),
            "id": str(users.get_current_user().user_id()),
            "counselor": counselor,
            "_expertises": _expertises,
        }

        self._output_template("counselor-edit.html", **template_vars)