Пример #1
0
 def create(self):
     """Insert new Source data into database."""
     source = model.Source()
     source.authorFirstName = h.NFD(self.form_result['authorFirstName'])
     source.authorLastName = h.NFD(self.form_result['authorLastName'])
     source.title = h.NFD(self.form_result['title'])
     source.year = self.form_result['year']
     source.fullReference = h.NFD(self.form_result['fullReference'])
     fileID = self.form_result['file_id']
     if fileID:
         file = meta.Session.query(model.File).get(int(fileID))
         if file:
             source.file = file
         else:
             html = render('/derived/source/add.html')
             values = self.form_result
             errors = {'file_id': 'There is no file with ID %s' % fileID}
             return htmlfill.render(html, defaults=values, errors=errors)
     # Enter the data
     meta.Session.add(source)
     meta.Session.commit()
     # Update the users variable in app_globals
     tags = h.getSecondaryObjects(['sources'])
     app_globals.sources = tags['sources']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='source', action='view', id=source.id)
     return "Moved temporarily"           
Пример #2
0
 def create(self):
     """Insert new Source data into database."""
     source = model.Source()
     source.authorFirstName = h.NFD(self.form_result['authorFirstName'])
     source.authorLastName = h.NFD(self.form_result['authorLastName'])
     source.title = h.NFD(self.form_result['title'])
     source.year = self.form_result['year']
     source.fullReference = h.NFD(self.form_result['fullReference'])
     fileID = self.form_result['file_id']
     if fileID:
         file = meta.Session.query(model.File).get(int(fileID))
         if file:
             source.file = file
         else:
             html = render('/derived/source/add.html')
             values = self.form_result
             errors = {'file_id': 'There is no file with ID %s' % fileID}
             return htmlfill.render(html, defaults=values, errors=errors)
     # Enter the data
     meta.Session.add(source)
     meta.Session.commit()
     # Update the users variable in app_globals
     tags = h.getSecondaryObjects(['sources'])
     app_globals.sources = tags['sources']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='source',
                                        action='view',
                                        id=source.id)
     return "Moved temporarily"
Пример #3
0
 def save(self):
     """Update OLD Keyword with newly altered data."""
     # Check whether the user is updating a keyword to have a
     #  name that is the same as another keyword and redisplay
     #  the form with an error message if so.  This should be
     #  done by the Schema, but I couldn't figure out how.
     otherKeywordsWithSameName = meta.Session.query(model.Keyword).filter(model.Keyword.id!=self.form_result['ID']).filter(model.Keyword.name==self.form_result['name']).all()
     if otherKeywordsWithSameName:
         c.keyword = meta.Session.query(model.Keyword).get(int(self.form_result['ID']))
         html = render('/derived/tag/keyword/edit.html')
         errors = {'name': 'Sorry, that name is already taken'}
         values = {
             'ID': self.form_result['ID'],
             'name': self.form_result['name'],
             'description': self.form_result['description']
         }
         return htmlfill.render(html, defaults=values, errors=errors)
     keyword_q = meta.Session.query(model.Keyword)
     keyword = keyword_q.get(int(self.form_result['ID']))        
     keyword.name = h.NFD(self.form_result['name'])
     keyword.description = h.NFD(self.form_result['description'])
     # Update the data
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='key', action='view', id=keyword.id)
     return "Moved temporarily"    
Пример #4
0
 def save(self):
     """Update OLD Keyword with newly altered data."""
     # Check whether the user is updating a keyword to have a
     #  name that is the same as another keyword and redisplay
     #  the form with an error message if so.  This should be
     #  done by the Schema, but I couldn't figure out how.
     otherKeywordsWithSameName = meta.Session.query(model.Keyword).filter(
         model.Keyword.id != self.form_result['ID']).filter(
             model.Keyword.name == self.form_result['name']).all()
     if otherKeywordsWithSameName:
         c.keyword = meta.Session.query(model.Keyword).get(
             int(self.form_result['ID']))
         html = render('/derived/tag/keyword/edit.html')
         errors = {'name': 'Sorry, that name is already taken'}
         values = {
             'ID': self.form_result['ID'],
             'name': self.form_result['name'],
             'description': self.form_result['description']
         }
         return htmlfill.render(html, defaults=values, errors=errors)
     keyword_q = meta.Session.query(model.Keyword)
     keyword = keyword_q.get(int(self.form_result['ID']))
     keyword.name = h.NFD(self.form_result['name'])
     keyword.description = h.NFD(self.form_result['description'])
     # Update the data
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='key',
                                        action='view',
                                        id=keyword.id)
     return "Moved temporarily"
Пример #5
0
 def save(self):
     """Update OLD ElicitationMethod with newly altered data."""
     # Check whether the user is updating a method to have a
     #  name that is the same as another method and redisplay
     #  the form with an error message if so.  This should be
     #  done by the Schema, but I couldn't figure out how.
     otherMethodsWithSameName = (
         meta.Session.query(model.ElicitationMethod)
         .filter(model.ElicitationMethod.id != self.form_result["ID"])
         .filter(model.ElicitationMethod.name == self.form_result["name"])
         .all()
     )
     if otherMethodsWithSameName:
         c.elicitationMethod = meta.Session.query(model.ElicitationMethod).get(int(self.form_result["ID"]))
         html = render("/derived/tag/method/edit.html")
         errors = {"name": "Sorry, that name is already taken"}
         values = {
             "ID": self.form_result["ID"],
             "name": self.form_result["name"],
             "description": self.form_result["description"],
         }
         return htmlfill.render(html, defaults=values, errors=errors)
     elicitationMethod_q = meta.Session.query(model.ElicitationMethod)
     elicitationMethod = elicitationMethod_q.get(int(self.form_result["ID"]))
     elicitationMethod.name = h.NFD(self.form_result["name"])
     elicitationMethod.description = h.NFD(self.form_result["description"])
     # Update the data
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(["elicitationMethods"])
     app_globals.elicitationMethods = tags["elicitationMethods"]
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers["location"] = url(controller="method", action="view", id=elicitationMethod.id)
     return "Moved temporarily"
Пример #6
0
 def create(self):
     """Insert new Keyword data into database."""
     keyword = model.Keyword()
     keyword.name = h.NFD(self.form_result['name'])
     keyword.description = h.NFD(self.form_result['description'])
     # Enter the data
     meta.Session.add(keyword)
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='key', action='view', id=keyword.id)
     return "Moved temporarily"           
Пример #7
0
 def create(self):
     """Insert new ElicitationMethod data into database."""
     elicitationMethod = model.ElicitationMethod()
     elicitationMethod.name = h.NFD(self.form_result["name"])
     elicitationMethod.description = h.NFD(self.form_result["description"])
     # Enter the data
     meta.Session.add(elicitationMethod)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(["elicitationMethods"])
     app_globals.elicitationMethods = tags["elicitationMethods"]
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers["location"] = url(controller="method", action="view", id=elicitationMethod.id)
     return "Moved temporarily"
Пример #8
0
 def delete(self, id):
     """Delete the BLD Speaker with ID=id."""
     if id is None:
         abort(404)
     speaker_q = meta.Session.query(model.Speaker)
     speaker = speaker_q.get(int(id))
     if speaker is None:
         abort(404)
     meta.Session.delete(speaker)
     meta.Session.commit()
     # Update the speaker variable in app_globals
     tags = h.getSecondaryObjects(['speakers'])
     app_globals.speakers = tags['speakers']
     session['flash'] = "Speaker %s has been deleted" % id
     session.save()
     redirect(url(controller='people'))
Пример #9
0
 def delete(self, id):
     """Delete the BLD Keyword with ID=id."""
     if id is None:
         abort(404)
     keyword_q = meta.Session.query(model.Keyword)
     keyword = keyword_q.get(int(id))
     if keyword is None:
         abort(404)
     meta.Session.delete(keyword)
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     session['flash'] = "Keyword %s has been deleted" % id
     session.save()
     redirect(url(controller='tag', action='index'))
Пример #10
0
 def delete(self, id):
     """Delete the BLD Category with ID=id."""
     if id is None:
         abort(404)
     category_q = meta.Session.query(model.SyntacticCategory)
     category = category_q.get(int(id))
     if category is None:
         abort(404)
     meta.Session.delete(category)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(['syncats'])
     app_globals.syncats = tags['syncats']
     session['flash'] = "Syntactic Category %s has been deleted" % id
     session.save()
     redirect(url(controller='tag', action='index'))
Пример #11
0
 def delete(self, id):
     """Delete the BLD Category with ID=id."""
     if id is None:
         abort(404)
     category_q = meta.Session.query(model.SyntacticCategory)
     category = category_q.get(int(id))
     if category is None:
         abort(404)
     meta.Session.delete(category)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(["syncats"])
     app_globals.syncats = tags["syncats"]
     session["flash"] = "Syntactic Category %s has been deleted" % id
     session.save()
     redirect(url(controller="tag", action="index"))
Пример #12
0
 def delete(self, id):
     """Delete the BLD Source with ID=id."""
     if id is None:
         abort(404)
     source_q = meta.Session.query(model.Source)
     source = source_q.get(int(id))
     if source is None:
         abort(404)
     meta.Session.delete(source)
     meta.Session.commit()
     # Update the users variable in app_globals
     tags = h.getSecondaryObjects(['sources'])
     app_globals.sources = tags['sources']
     session['flash'] = "Source %s has been deleted" % id
     session.save()
     redirect(url(controller='source'))
Пример #13
0
 def delete(self, id):
     """Delete the BLD Source with ID=id."""
     if id is None:
         abort(404)
     source_q = meta.Session.query(model.Source)
     source = source_q.get(int(id))
     if source is None:
         abort(404)
     meta.Session.delete(source)
     meta.Session.commit()
     # Update the users variable in app_globals
     tags = h.getSecondaryObjects(['sources'])
     app_globals.sources = tags['sources']
     session['flash'] = "Source %s has been deleted" % id
     session.save()
     redirect(url(controller='source'))
Пример #14
0
 def delete(self, id):
     """Delete the BLD Keyword with ID=id."""
     if id is None:
         abort(404)
     keyword_q = meta.Session.query(model.Keyword)
     keyword = keyword_q.get(int(id))
     if keyword is None:
         abort(404)
     meta.Session.delete(keyword)
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     session['flash'] = "Keyword %s has been deleted" % id
     session.save()
     redirect(url(controller='tag', action='index'))
Пример #15
0
 def delete(self, id):
     """Delete the BLD ElicitationMethod with ID=id."""
     if id is None:
         abort(404)
     elicitationMethod_q = meta.Session.query(model.ElicitationMethod)
     elicitationMethod = elicitationMethod_q.get(int(id))
     if elicitationMethod is None:
         abort(404)
     meta.Session.delete(elicitationMethod)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(['elicitationMethods'])
     app_globals.elicitationMethods = tags['elicitationMethods']
     session['flash'] = "Elicitation Method %s has been deleted" % id
     session.save()
     redirect(url(controller='tag', action='index'))
Пример #16
0
 def delete(self, id):
     """Delete the BLD ElicitationMethod with ID=id."""
     if id is None:
         abort(404)
     elicitationMethod_q = meta.Session.query(model.ElicitationMethod)
     elicitationMethod = elicitationMethod_q.get(int(id))
     if elicitationMethod is None:
         abort(404)
     meta.Session.delete(elicitationMethod)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(["elicitationMethods"])
     app_globals.elicitationMethods = tags["elicitationMethods"]
     session["flash"] = "Elicitation Method %s has been deleted" % id
     session.save()
     redirect(url(controller="tag", action="index"))
Пример #17
0
 def create(self):
     """Insert new Keyword data into database."""
     keyword = model.Keyword()
     keyword.name = h.NFD(self.form_result['name'])
     keyword.description = h.NFD(self.form_result['description'])
     # Enter the data
     meta.Session.add(keyword)
     meta.Session.commit()
     # Update the keywords variable in app_globals
     tags = h.getSecondaryObjects(['keywords'])
     app_globals.keywords = tags['keywords']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='key',
                                        action='view',
                                        id=keyword.id)
     return "Moved temporarily"
Пример #18
0
 def create(self):
     """Insert new ElicitationMethod data into database."""
     elicitationMethod = model.ElicitationMethod()
     elicitationMethod.name = h.NFD(self.form_result['name'])
     elicitationMethod.description = h.NFD(self.form_result['description'])
     # Enter the data
     meta.Session.add(elicitationMethod)
     meta.Session.commit()
     # Update the syncats variable in app_globals
     tags = h.getSecondaryObjects(['elicitationMethods'])
     app_globals.elicitationMethods = tags['elicitationMethods']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='method',
                                        action='view',
                                        id=elicitationMethod.id)
     return "Moved temporarily"
Пример #19
0
 def save(self):
     """Update OLD Speaker with newly altered data."""
     speaker_q = meta.Session.query(model.Speaker)
     speaker = speaker_q.get(int(self.form_result['ID']))        
     speaker.firstName = h.NFD(self.form_result['firstName'])
     speaker.lastName = h.NFD(self.form_result['lastName'])
     speaker.dialect = h.NFD(self.form_result['dialect'])
     speaker.speakerPageContent = h.NFD(self.form_result['speakerPageContent'])
     # Update the data
     meta.Session.commit()
     # Update the speaker variable in app_globals
     tags = h.getSecondaryObjects(['speakers'])
     app_globals.speakers = tags['speakers']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='speaker', action='view', id=speaker.id)
     return "Moved temporarily"    
Пример #20
0
 def create(self):
     """Insert new Speaker data into database."""
     speaker = model.Speaker()
     speaker.firstName = h.NFD(self.form_result['firstName'])
     speaker.lastName = h.NFD(self.form_result['lastName'])
     speaker.dialect = h.NFD(self.form_result['dialect'])
     speaker.speakerPageContent = h.NFD(self.form_result['speakerPageContent'])
     # Enter the data
     meta.Session.add(speaker)
     meta.Session.commit()
     # Update the speaker variable in app_globals
     tags = h.getSecondaryObjects(['speakers'])
     app_globals.speakers = tags['speakers']
     # Issue an HTTP redirect
     response.status_int = 302
     response.headers['location'] = url(controller='speaker', action='view', id=speaker.id)
     return "Moved temporarily"           
Пример #21
0
    def create(self):
        """Insert new Category data into database.

        """

        category = model.SyntacticCategory()
        category.name = h.NFD(self.form_result["name"])
        category.description = h.NFD(self.form_result["description"])
        # Enter the data
        meta.Session.add(category)
        meta.Session.commit()
        # Update the syncats variable in app_globals
        tags = h.getSecondaryObjects(["syncats"])
        app_globals.syncats = tags["syncats"]
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers["location"] = url(controller="category", action="view", id=category.id)
        return "Moved temporarily"
Пример #22
0
    def create(self):
        """Insert new Category data into database.

        """

        category = model.SyntacticCategory()
        category.name = h.NFD(self.form_result['name'])
        category.description = h.NFD(self.form_result['description'])
        # Enter the data
        meta.Session.add(category)
        meta.Session.commit()
        # Update the syncats variable in app_globals
        tags = h.getSecondaryObjects(['syncats'])
        app_globals.syncats = tags['syncats']
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers['location'] = url(controller='category',
                                           action='view',
                                           id=category.id)
        return "Moved temporarily"
Пример #23
0
    def save(self):
        """Update OLD Researcher with newly altered data.
        
        """

        researcher_q = meta.Session.query(model.User)
        researcher = researcher_q.get(int(self.form_result["ID"]))
        getResearcherAttributes(researcher, self.form_result, "save")
        # Update the data
        meta.Session.commit()
        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(["users"])
        app_globals.users = tags["users"]
        # update the session if we have just updated the current user
        if researcher.id == session["user_id"]:
            h.getAuthorizedUserIntoSession(researcher)
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers["location"] = url(controller="researcher", action="view", id=researcher.id)
        return "Moved temporarily"
Пример #24
0
    def create(self):
        """Insert new Researcher data into database.
        
        """

        researcher = model.User()
        getResearcherAttributes(researcher, self.form_result, "create")

        # Create a directory in files directory for this researcher
        h.createResearcherDirectory(researcher)

        # Enter the data
        meta.Session.add(researcher)
        meta.Session.commit()
        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(["users"])
        app_globals.users = tags["users"]
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers["location"] = url(controller="researcher", action="view", id=researcher.id)
        return "Moved temporarily"
Пример #25
0
    def save(self):
        """Update OLD Researcher with newly altered data.
        
        """

        researcher_q = meta.Session.query(model.User)
        researcher = researcher_q.get(int(self.form_result['ID']))
        getResearcherAttributes(researcher, self.form_result, 'save')
        # Update the data
        meta.Session.commit()
        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(['users'])
        app_globals.users = tags['users']
        # update the session if we have just updated the current user
        if researcher.id == session['user_id']:
            h.getAuthorizedUserIntoSession(researcher)
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers['location'] = url(controller='researcher',
                                           action='view',
                                           id=researcher.id)
        return "Moved temporarily"
Пример #26
0
    def delete(self, id):
        """Delete the BLD Researcher with ID=id.
        
        """

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

        # Destroy the researcher's directory in the files directory
        h.destroyResearcherDirectory(researcher)

        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(["users"])
        app_globals.users = tags["users"]
        session["flash"] = "Researcher %s has been deleted" % id
        session.save()
        redirect(url(controller="people"))
Пример #27
0
    def delete(self, id):
        """Delete the BLD Researcher with ID=id.
        
        """

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

        # Destroy the researcher's directory in the files directory
        h.destroyResearcherDirectory(researcher)

        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(['users'])
        app_globals.users = tags['users']
        session['flash'] = "Researcher %s has been deleted" % id
        session.save()
        redirect(url(controller='people'))
Пример #28
0
    def create(self):
        """Insert new Researcher data into database.
        
        """

        researcher = model.User()
        getResearcherAttributes(researcher, self.form_result, 'create')

        # Create a directory in files directory for this researcher
        h.createResearcherDirectory(researcher)

        # Enter the data
        meta.Session.add(researcher)
        meta.Session.commit()
        # Update the users variable in app_globals
        tags = h.getSecondaryObjects(['users'])
        app_globals.users = tags['users']
        # Issue an HTTP redirect
        response.status_int = 302
        response.headers['location'] = url(controller='researcher',
                                           action='view',
                                           id=researcher.id)
        return "Moved temporarily"