コード例 #1
0
ファイル: researcher.py プロジェクト: pombredanne/old-webapp
    def savesettings(self, id):
        """Save the newly changed user-specific settings.
        
        """

        if id is None:
            abort(404)

        researcher_q = meta.Session.query(model.User)
        c.researcher = researcher_q.get(int(id))
        if c.researcher is None:
            abort(404)

        # Save settings in the researcher's settings pickle
        researcherSettings = {
            'inputOrthography':
            self.form_result['inputOrthography'],
            'outputOrthography':
            self.form_result['outputOrthography'],
            'defaultMetadataFromPreviousForm':
            self.form_result['defaultMetadataFromPreviousForm'],
            'defaultFormView':
            self.form_result['defaultFormView'],
            'guessMorphology':
            self.form_result['guessMorphology'],
            'dateFormat':
            self.form_result['dateFormat']
        }
        h.pickleResearcherSettings(researcherSettings, c.researcher)

        session['userSettings'] = researcherSettings
        # Save settings in session
        session['user_inputOrthography'] = researcherSettings[
            'inputOrthography']
        session['user_outputOrthography'] = researcherSettings[
            'outputOrthography']
        session['user_defaultMetadataFromPreviousForm'] = researcherSettings[
            'defaultMetadataFromPreviousForm']
        session['defaultFormView'] = researcherSettings['defaultFormView']
        session['guessMorphology'] = researcherSettings['guessMorphology']
        session['dateFormat'] = researcherSettings['dateFormat']

        # Put the appropriate translators in the session.
        #  That is, if the user has chosen an output orthography that is
        #  different from the storage orthography AND is different from the
        #  default output orthography, create a new translator in the session.
        #  Ditto for the input-to-storage translator.
        h.putOrthographyTranslatorsIntoSession()

        session.save()

        # Issue an HTTP redirect
        response.status_int = 302
        response.headers['location'] = url(controller='researcher', \
                                        action='settings', id=c.researcher.id)
        return "Moved temporarily"
コード例 #2
0
ファイル: researcher.py プロジェクト: jrwdunham/old-webapp
    def saveuserdisplaysetting(self):
        """Asynchronously saves the user's form add display settings, i.e.,
        whether the narrow or broad phonetic transcription fields will be
        displayed or not.  See the saveUserDisplaySetting JS function in
        functions.js.
        
        """

        value = {"true": True, "false": False}[request.params["value"]]
        setting = request.params["setting"]
        researcher = meta.Session.query(model.User).get(session["user_id"])
        researcherSettings = h.unpickleResearcherSettings(researcher)
        researcherSettings[setting] = value
        h.pickleResearcherSettings(researcherSettings, researcher)
        session["userSettings"] = researcherSettings
        session.save()
コード例 #3
0
ファイル: researcher.py プロジェクト: pombredanne/old-webapp
    def saveuserdisplaysetting(self):
        """Asynchronously saves the user's form add display settings, i.e.,
        whether the narrow or broad phonetic transcription fields will be
        displayed or not.  See the saveUserDisplaySetting JS function in
        functions.js.
        
        """

        value = {'true': True, 'false': False}[request.params['value']]
        setting = request.params['setting']
        researcher = meta.Session.query(model.User).get(session['user_id'])
        researcherSettings = h.unpickleResearcherSettings(researcher)
        researcherSettings[setting] = value
        h.pickleResearcherSettings(researcherSettings, researcher)
        session['userSettings'] = researcherSettings
        session.save()
コード例 #4
0
ファイル: researcher.py プロジェクト: jrwdunham/old-webapp
    def savesettings(self, id):
        """Save the newly changed user-specific settings.
        
        """

        if id is None:
            abort(404)

        researcher_q = meta.Session.query(model.User)
        c.researcher = researcher_q.get(int(id))
        if c.researcher is None:
            abort(404)

        # Save settings in the researcher's settings pickle
        researcherSettings = {
            "inputOrthography": self.form_result["inputOrthography"],
            "outputOrthography": self.form_result["outputOrthography"],
            "defaultMetadataFromPreviousForm": self.form_result["defaultMetadataFromPreviousForm"],
            "defaultFormView": self.form_result["defaultFormView"],
            "guessMorphology": self.form_result["guessMorphology"],
            "dateFormat": self.form_result["dateFormat"],
        }
        h.pickleResearcherSettings(researcherSettings, c.researcher)

        session["userSettings"] = researcherSettings
        # Save settings in session
        session["user_inputOrthography"] = researcherSettings["inputOrthography"]
        session["user_outputOrthography"] = researcherSettings["outputOrthography"]
        session["user_defaultMetadataFromPreviousForm"] = researcherSettings["defaultMetadataFromPreviousForm"]
        session["defaultFormView"] = researcherSettings["defaultFormView"]
        session["guessMorphology"] = researcherSettings["guessMorphology"]
        session["dateFormat"] = researcherSettings["dateFormat"]

        # Put the appropriate translators in the session.
        #  That is, if the user has chosen an output orthography that is
        #  different from the storage orthography AND is different from the
        #  default output orthography, create a new translator in the session.
        #  Ditto for the input-to-storage translator.
        h.putOrthographyTranslatorsIntoSession()

        session.save()

        # Issue an HTTP redirect
        response.status_int = 302
        response.headers["location"] = url(controller="researcher", action="settings", id=c.researcher.id)
        return "Moved temporarily"