Пример #1
0
def renderAddCollection(values=None, errors=None, addUpdate='add'):
    """Function is called by both the add and update actions to create the
    Add Collection and Update Collection HTML forms.  The create and save
    actions can also call this function if any errors are present in the input.
    
    """

    # if addUpdate is set to 'update', render update.html instead of add.html
    if addUpdate == 'add':
        html = render('/derived/collection/add.html')
    else:
        html = render('/derived/collection/update.html')

    return htmlfill.render(html, defaults=values, errors=errors)
Пример #2
0
def renderAddCollection(values=None, errors=None, addUpdate='add'):
    """Function is called by both the add and update actions to create the
    Add Collection and Update Collection HTML forms.  The create and save
    actions can also call this function if any errors are present in the input.
    
    """
    
    # if addUpdate is set to 'update', render update.html instead of add.html
    if addUpdate == 'add':
        html = render('/derived/collection/add.html')
    else:
        html = render('/derived/collection/update.html')

    return htmlfill.render(html, defaults=values, errors=errors)
Пример #3
0
    def associate(self, id):
        """Display the page for associating a BLD File with id=id to a BLD Form.
        The HTML form in the rendered page references the link action.

        """

        if id is None:
            abort(404)
        c.file = meta.Session.query(model.File).get(int(id))  
        if c.file is None:
            abort(404)
        c.associateForm = render('/derived/file/associateForm.html')

        return render('/derived/file/associate.html')
Пример #4
0
    def associate(self, id):
        """Display the page for associating a BLD File with id=id to a BLD Form.
        The HTML form in the rendered page references the link action.

        """

        if id is None:
            abort(404)
        c.file = meta.Session.query(model.File).get(int(id))
        if c.file is None:
            abort(404)
        c.associateForm = render('/derived/file/associateForm.html')

        return render('/derived/file/associate.html')
Пример #5
0
    def orthography(self):
        """Renders the Orthographies & Inventories page.
        
        Allows users to see if they can correctly enter the graphs of the
        orthographies and to test the orthography conversion.

        """

        c.applicationSettings = meta.Session.query(
            model.ApplicationSettings).order_by(
                desc(model.ApplicationSettings.id
                )
            ).first()

        # Get obj lang orthographies as Inventoriy objects
        c.orthographiesAsInventories = getOrthographiesAsInventories(
                                                        c.applicationSettings)

        # Get metalanguage orthography, and other graph sets as Inventory objects
        getInventoriesAsPropertiesOfC(c.applicationSettings)

        c.orthOptions = [(id, c.orthographiesAsInventories[id][0])
                        for id in c.orthographiesAsInventories]

        return render('/derived/settings/orthography.html')
Пример #6
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"
Пример #7
0
    def create(self, input, option):
        """Create the export file in file/researcher.username"""
        
        # Get the appropriate exporter instance via the option variable
        exporterIndex = int(option[6:])
        exporter = exporters[exporterIndex]
        
        # Create the export string
        exportString = exporter.export(input)
        
        # Create the export file (simultaneously overwriting this user's
        #  previous export file)
        c.filename = '%s.%s' % (session['user_username'], exporter.extension)
        filePath = os.path.join(
            config['app_conf']['permanent_store'],
            'researchers',
            session['user_username'],
            c.filename
        )
        file = codecs.open(filePath, encoding='utf-8', mode='w')
        file.write(exportString)

        c.fileRetrieveName = os.path.join(
            'researchers', session['user_username'], c.filename)
        return render('/derived/export/create.html')
Пример #8
0
    def edit(self, id):
        """Edit an OLD Researcher.  A non-administrator can only edit their own
        information; hence the userIDIsArgs1=True argument in the authorize
        validator.
        
        """

        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)
        html = render("/derived/people/researcher/edit.html")
        values = {
            "ID": c.researcher.id,
            "username": c.researcher.username,
            "firstName": c.researcher.firstName,
            "lastName": c.researcher.lastName,
            "email": c.researcher.email,
            "affiliation": c.researcher.affiliation,
            "personalPageContent": c.researcher.personalPageContent,
            "role": c.researcher.role,
        }
        return htmlfill.render(html, values)
Пример #9
0
    def save(self):
        """Save the changed application settings.

        This action both saves the application settings to the model and updates
        app_globals with the application settings info.

        """

        c.colorsCSSOptions = os.listdir(os.path.join(
            config['pylons.paths']['root'], 'public', 'css', 'colors'
        ))

        schema = AlterSettingsForm()
        values = dict(request.params)
        try:
            self.form_result = schema.to_python(dict(request.params), c)
        except Invalid, e:
            return renderEditSettings(
                values=values,
                errors=variabledecode.variable_encode(
                    e.unpack_errors() or {},
                    add_repetitions=False
                )
            )
            return render('/derived/settings/index.html')
Пример #10
0
    def edit(self, id):
        """Edit an OLD Researcher.  A non-administrator can only edit their own
        information; hence the userIDIsArgs1=True argument in the authorize
        validator.
        
        """

        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)
        html = render('/derived/people/researcher/edit.html')
        values = {
            'ID': c.researcher.id,
            'username': c.researcher.username,
            'firstName': c.researcher.firstName,
            'lastName': c.researcher.lastName,
            'email': c.researcher.email,
            'affiliation': c.researcher.affiliation,
            'personalPageContent': c.researcher.personalPageContent,
            'role': c.researcher.role
        }
        return htmlfill.render(html, values)
Пример #11
0
 def index(self):
     """View all Sources."""
     c.sources = meta.Session.query(model.Source).order_by(
         model.Source.authorLastName).order_by(
             model.Source.authorFirstName).order_by(desc(
                 model.Source.year)).all()
     return render('/derived/source/index.html')
Пример #12
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"
Пример #13
0
 def index(self):
     speaker_q = meta.Session.query(model.Speaker).order_by(
         model.Speaker.lastName)
     c.speakers = speaker_q.all()
     user_q = meta.Session.query(model.User).order_by(model.User.lastName)
     c.users = user_q.all()
     return render('/derived/people/index.html')
Пример #14
0
    def olduserguide(self):
        """The olduserguide action displays the general-purpose OLD User Guide
        as generated from the user_guide.txt ReST file in the docs directory.
        
        """

        return render("/derived/help/oldUserGuide.html")
Пример #15
0
    def index(self):
        """Display the OLD Application home page.  This page is generated from
        the entry with name='home' of the table page_table of the model.  This
        page can be edited by administrators.
        
        """
        
        # Get the number of Forms in the db
        c.formCount = str(h.getFormCount())
        
        # Get the homepage from the model
        homepage_q = meta.Session.query(model.Page).filter(
            model.Page.name==u'home')
        homepage = homepage_q.first()

        try:
            c.heading = homepage.heading
            c.content = homepage.content
        except AttributeError:
            c.heading = u'There is no heading'
            c.content = u'There is no content for this page'

        # Convert reStructuredText to HTML
        c.content = h.rst2html(c.content)
        
        # Convert OLD Markup references to links/representations
        c.content = linkToOLDEntitites(c.content)
        c.content = embedFiles(c.content)
        c.content = embedForms(c.content)
        
        return render('/derived/home/index.html')
Пример #16
0
    def export(self, id=None):
        """Export the BLD Files matching the search criteria
        as a .zip archive.  ."""
        # Get the Files that match the search and get their full path names
        try:
            result = session['fileSearchValues']
            file_q = meta.Session.query(model.File)
            file_q = h.filterSearchQuery(result, file_q, 'File')
            files = file_q.all()
        except KeyError:
            files = meta.Session.query(model.File).all()

        fileNames = [
            os.path.join(config['app_conf']['permanent_store'], file.name)
            for file in files
        ]

        # Create the .zip file and write the Files to it
        #  Python 2.5 was raising a UnicodeDecodeError when ZipFile.write was
        #  passed unicode arguments, so I've str()-ed them
        zfileName = str('%s_%s_file_export.zip' % \
            (session['user_firstName'].lower(), session['user_lastName'].lower()))
        zfileName = str(
            os.path.join(config['app_conf']['temporary_store'], zfileName))
        zout = zipfile.ZipFile(zfileName, "w")
        for fileName in fileNames:
            zout.write(str(fileName), os.path.basename(str(fileName)))
        zout.close()
        c.zfileName = os.path.basename(zfileName)
        c.zfileSize = os.path.getsize(zfileName)
        c.fileNames = [(file.name,
                        os.path.getsize(
                            os.path.join(config['app_conf']['permanent_store'],
                                         file.name))) for file in files]
        return render('/derived/file/export.html')
Пример #17
0
    def olduserguide(self):
        """The olduserguide action displays the general-purpose OLD User Guide
        as generated from the user_guide.txt ReST file in the docs directory.
        
        """

        return render('/derived/help/oldUserGuide.html')
Пример #18
0
    def editsettings(self, id):
        """Edit the logged in researcher's 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)

        # Get the researcher's settings from the pickle file in
        #  files/researchers/username/username.pickle
        c.researcherSettings = h.unpickleResearcherSettings(c.researcher)

        values = {
            'inputOrthography':
            c.researcherSettings.get('inputOrthography'),
            'outputOrthography':
            c.researcherSettings.get('outputOrthography'),
            'defaultMetadataFromPreviousForm':
            c.researcherSettings.get('defaultMetadataFromPreviousForm'),
            'defaultFormView':
            c.researcherSettings.get('defaultFormView'),
            'guessMorphology':
            c.researcherSettings.get('guessMorphology'),
            'dateFormat':
            c.researcherSettings.get('dateFormat')
        }

        html = render('/derived/people/researcher/editsettings.html')

        return htmlfill.render(html, defaults=values)
Пример #19
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"    
Пример #20
0
    def add(self):
        """Add a new OLD Researcher.  This action renders the html form 
        for adding a new Researcher.  This form calls the create action.
        
        """

        return render("/derived/people/researcher/add.html")
Пример #21
0
    def export(self, id=None):
        """Export the BLD Files matching the search criteria
        as a .zip archive.  ."""
        # Get the Files that match the search and get their full path names
        try:
            result = session['fileSearchValues']
            file_q = meta.Session.query(model.File)
            file_q = h.filterSearchQuery(result, file_q, 'File')
            files = file_q.all()
        except KeyError:
            files = meta.Session.query(model.File).all()

        fileNames = [os.path.join(config['app_conf']['permanent_store'], file.name) for file in files]

        # Create the .zip file and write the Files to it
        #  Python 2.5 was raising a UnicodeDecodeError when ZipFile.write was
        #  passed unicode arguments, so I've str()-ed them
        zfileName = str('%s_%s_file_export.zip' % \
            (session['user_firstName'].lower(), session['user_lastName'].lower()))
        zfileName = str(
            os.path.join(config['app_conf']['temporary_store'], zfileName))
        zout = zipfile.ZipFile(zfileName, "w")
        for fileName in fileNames:
            zout.write(str(fileName), os.path.basename(str(fileName)))
        zout.close()
        c.zfileName = os.path.basename(zfileName)
        c.zfileSize = os.path.getsize(zfileName)
        c.fileNames = [(file.name, os.path.getsize(os.path.join(config['app_conf']['permanent_store'], file.name))) for file in files]
        return render('/derived/file/export.html')
Пример #22
0
    def index(self):
        """View the application settings.
        
        """

        # Query the model for the application settings
        c.applicationSettings = meta.Session.query(
            model.ApplicationSettings).order_by(
                desc(model.ApplicationSettings.id)).first()

        # Get obj lang orthographies as Inventoriy objects
        c.orthographiesAsInventories = getOrthographiesAsInventories(
            c.applicationSettings)

        # Get metalanguage orthography, and other graph sets as Inventory objects
        getInventoriesAsPropertiesOfC(c.applicationSettings)

        # Get info about the database/RDBMS being used
        SQLAlchemyURL = config['sqlalchemy.url']
        c.rdbms = SQLAlchemyURL.split(':')[0]
        c.databaseName = SQLAlchemyURL.split('/')[-1]

        c.unrestrictedUsers = app_globals.unrestrictedUsers

        return render('/derived/settings/index.html')
Пример #23
0
    def add(self):
        """Add a new OLD Researcher.  This action renders the html form 
        for adding a new Researcher.  This form calls the create action.
        
        """

        return render('/derived/people/researcher/add.html')
Пример #24
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"
Пример #25
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"           
Пример #26
0
    def editsettings(self, id):
        """Edit the logged in researcher's 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)

        # Get the researcher's settings from the pickle file in
        #  files/researchers/username/username.pickle
        c.researcherSettings = h.unpickleResearcherSettings(c.researcher)

        values = {
            "inputOrthography": c.researcherSettings.get("inputOrthography"),
            "outputOrthography": c.researcherSettings.get("outputOrthography"),
            "defaultMetadataFromPreviousForm": c.researcherSettings.get("defaultMetadataFromPreviousForm"),
            "defaultFormView": c.researcherSettings.get("defaultFormView"),
            "guessMorphology": c.researcherSettings.get("guessMorphology"),
            "dateFormat": c.researcherSettings.get("dateFormat"),
        }

        html = render("/derived/people/researcher/editsettings.html")

        return htmlfill.render(html, defaults=values)
Пример #27
0
 def index(self):
     speaker_q = meta.Session.query(model.Speaker).order_by(
         model.Speaker.lastName)
     c.speakers = speaker_q.all()
     user_q = meta.Session.query(model.User).order_by(model.User.lastName)
     c.users = user_q.all()
     return render('/derived/people/index.html')
Пример #28
0
    def login(self):
        """Renders the login.html page for authentication.  login.html calls the
        authenticate action.
        
        """

        return render('/derived/login/login.html')
Пример #29
0
 def login(self):
     """Renders the login.html page for authentication.  login.html calls the
     authenticate action.
     
     """
     
     return render('/derived/login/login.html')
Пример #30
0
    def index(self):
        """View the application settings.
        
        """

        # Query the model for the application settings
        c.applicationSettings = meta.Session.query(
            model.ApplicationSettings).order_by(
                desc(model.ApplicationSettings.id
                )
            ).first()

        # Get obj lang orthographies as Inventoriy objects
        c.orthographiesAsInventories = getOrthographiesAsInventories(
                                                        c.applicationSettings)

        # Get metalanguage orthography, and other graph sets as Inventory objects
        getInventoriesAsPropertiesOfC(c.applicationSettings)

        # Get info about the database/RDBMS being used
        SQLAlchemyURL = config['sqlalchemy.url']
        c.rdbms = SQLAlchemyURL.split(':')[0]
        c.databaseName = SQLAlchemyURL.split('/')[-1]
        
        c.unrestrictedUsers = app_globals.unrestrictedUsers

        return render('/derived/settings/index.html')
Пример #31
0
    def search(self, values=None, errors=None):
        """Display HTML form for searching in Dictionary mode.  HTML form calls
        query action.
        
        """

        html = render('/derived/dictionary/search.html')
        return htmlfill.render(html, defaults=values, errors=errors)
Пример #32
0
def renderEditSettings(values=None, errors=None):
    """Function is called by the edit action to create the Edit Application
    Settings HTML form.
    
    """

    html = render('/derived/settings/edit.html')
    return htmlfill.render(html, defaults=values, errors=errors)
Пример #33
0
 def search(self, values=None, errors=None):
     """Display HTML form for searching in Dictionary mode.  HTML form calls
     query action.
     
     """
     
     html = render('/derived/dictionary/search.html')
     return htmlfill.render(html, defaults=values, errors=errors)
Пример #34
0
def renderEditSettings(values=None, errors=None):
    """Function is called by the edit action to create the Edit Application
    Settings HTML form.
    
    """

    html = render('/derived/settings/edit.html')
    return htmlfill.render(html, defaults=values, errors=errors)
Пример #35
0
 def view(self, id):
     """View an OLD Syntactic Category.  Requires a Category ID as input."""
     if id is None:
         redirect(url(controller="tag", action="index"))
     category_q = meta.Session.query(model.SyntacticCategory)
     c.category = category_q.get(int(id))
     if c.category is None:
         abort(404)
     return render("/derived/tag/category/view.html")
Пример #36
0
 def view(self, id):
     """View an OLD Source.  Requires a Source ID as input."""
     if id is None:
         abort(404)
     source_q = meta.Session.query(model.Source)
     c.source = source_q.get(int(id))
     if c.source is None:
         abort(404)
     return render('/derived/source/view.html')
Пример #37
0
 def view(self, id):
     """View an OLD Source.  Requires a Source ID as input."""
     if id is None:
         abort(404)
     source_q = meta.Session.query(model.Source)
     c.source = source_q.get(int(id))
     if c.source is None:
         abort(404)
     return render('/derived/source/view.html')
Пример #38
0
 def view(self, id):
     """View an OLD Keyword.  Requires a Keyword ID as input."""
     if id is None:
         redirect(url(controller='tag', action='index'))
     keyword_q = meta.Session.query(model.Keyword)
     c.keyword = keyword_q.get(int(id))
     if c.keyword is None:
         abort(404)
     return render('/derived/tag/keyword/view.html')
Пример #39
0
 def view(self, id):
     """View an OLD Syntactic Category.  Requires a Category ID as input."""
     if id is None:
         redirect(url(controller='tag', action='index'))
     category_q = meta.Session.query(model.SyntacticCategory)
     c.category = category_q.get(int(id))
     if c.category is None:
         abort(404)
     return render('/derived/tag/category/view.html')
Пример #40
0
 def browse(self):
     """Browse through all Files in the system."""
     file_q = meta.Session.query(model.File).order_by(model.File.name)
     c.paginator = paginate.Page(
         file_q,
         page=int(request.params.get('page', 1)),
         items_per_page=app_globals.file_items_per_page)
     c.browsing = True
     return render('/derived/file/results.html')
Пример #41
0
 def view(self, id):
     """View an OLD Keyword.  Requires a Keyword ID as input."""
     if id is None:
         redirect(url(controller='tag', action='index'))
     keyword_q = meta.Session.query(model.Keyword)
     c.keyword = keyword_q.get(int(id))
     if c.keyword is None:
         abort(404)
     return render('/derived/tag/keyword/view.html')
Пример #42
0
 def associate(self, id):
     """Display the page for associating a BLD Collection with id=id 
     to a BLD File.  The HTML form in the rendered page ultimately
     references the link action."""
     if id is None:
         abort(404)
     c.collection = meta.Session.query(model.Collection).get(int(id))  
     if c.collection is None:
         abort(404)   
     return render('/derived/collection/associate.html')
Пример #43
0
 def associate(self, id):
     """Display the page for associating a BLD Collection with id=id 
     to a BLD File.  The HTML form in the rendered page ultimately
     references the link action."""
     if id is None:
         abort(404)
     c.collection = meta.Session.query(model.Collection).get(int(id))
     if c.collection is None:
         abort(404)
     return render('/derived/collection/associate.html')
Пример #44
0
 def browse(self):
     """Browse through all Files in the system."""
     file_q = meta.Session.query(model.File).order_by(model.File.name)
     c.paginator = paginate.Page(
         file_q,
         page=int(request.params.get('page', 1)),
         items_per_page = app_globals.file_items_per_page
     )
     c.browsing = True
     return render('/derived/file/results.html')
Пример #45
0
 def index(self):
     checkRequirements()
     try:
         phonologyFilePath = os.path.join(parserDataDir, phonologyFileName)
         phonologyFile = codecs.open(phonologyFilePath, 'r', 'utf-8')
         c.phonology = phonologyFile.read()
         phonologyFile.close()
     except IOError:
         c.phonology = u''
     return render('/derived/morphparser/index.html')
Пример #46
0
 def index(self):
     """Render the 'memory/index.html' page which displays
     the Forms that the user has stored in memory."""
     # Get all Forms that user has memorized ordered by Form ID 
     #  by using the 'memorizers' backreference
     user = meta.Session.query(model.User).filter(
         model.User.id==session['user_id']).first()
     c.rememberedForms = meta.Session.query(model.Form).order_by(desc(
         model.Form.id)).filter(model.Form.memorizers.contains(user)).all() 
     return render('/derived/memory/index.html')
Пример #47
0
 def index(self):
     checkRequirements()
     try:
         phonologyFilePath = os.path.join(parserDataDir, phonologyFileName)
         phonologyFile = codecs.open(phonologyFilePath, 'r', 'utf-8')
         c.phonology = phonologyFile.read()
         phonologyFile.close()
     except IOError:
         c.phonology = u''
     return render('/derived/morphparser/index.html')
Пример #48
0
 def edit(self, id):
     """Edit an OLD Category."""
     if id is None:
         abort(404)
     category_q = meta.Session.query(model.SyntacticCategory)
     c.category = category_q.get(int(id))
     if c.category is None:
         abort(404)
     html = render("/derived/tag/category/edit.html")
     values = {"ID": c.category.id, "name": c.category.name, "description": c.category.description}
     return htmlfill.render(html, values)
Пример #49
0
 def index(self):
     keyword_q = meta.Session.query(model.Keyword).order_by(
         model.Keyword.name)
     c.keywords = keyword_q.all()
     syncat_q = meta.Session.query(model.SyntacticCategory).order_by(
         model.SyntacticCategory.name)
     c.syncats = syncat_q.all()
     elicitationMethod_q = meta.Session.query(
         model.ElicitationMethod).order_by(model.ElicitationMethod.name)
     c.elicitationMethods = elicitationMethod_q.all()
     return render('/derived/tag/index.html')
Пример #50
0
 def view(self, id):
     """View an OLD Elicitation Method.  Requires a ElicitationMethod ID as
     input.
     """
     if id is None:
         redirect(url(controller="tag", action="index"))
     elicitationMethod_q = meta.Session.query(model.ElicitationMethod)
     c.elicitationMethod = elicitationMethod_q.get(int(id))
     if c.elicitationMethod is None:
         abort(404)
     return render("/derived/tag/method/view.html")
Пример #51
0
 def index(self):
     """Render the 'memory/index.html' page which displays
     the Forms that the user has stored in memory."""
     # Get all Forms that user has memorized ordered by Form ID
     #  by using the 'memorizers' backreference
     user = meta.Session.query(
         model.User).filter(model.User.id == session['user_id']).first()
     c.rememberedForms = meta.Session.query(model.Form).order_by(
         desc(model.Form.id)).filter(
             model.Form.memorizers.contains(user)).all()
     return render('/derived/memory/index.html')
Пример #52
0
 def view(self, id):
     """View an OLD Elicitation Method.  Requires a ElicitationMethod ID as
     input.
     """
     if id is None:
         redirect(url(controller='tag', action='index'))
     elicitationMethod_q = meta.Session.query(model.ElicitationMethod)
     c.elicitationMethod = elicitationMethod_q.get(int(id))
     if c.elicitationMethod is None:
         abort(404)
     return render('/derived/tag/method/view.html')
Пример #53
0
def renderAddFile(values=None, errors=None, addUpdate='add'):
    """Function is called by both the add and update actions to create the
    Add File and Update File HTML forms.  The create and save actions can also
    call this function if any errors are present in the input.
    
    """

    # if addUpdate is set to 'update', render update.html instead of add.html
    if addUpdate == 'add':
        form = render('/derived/file/addForm.html')
        c.heading = u'Add a File'
        c.filledForm = htmlfill.render(form, defaults=values, errors=errors)
        page = render('/derived/file/add.html')
    else:
        form = render('/derived/file/updateForm.html')
        c.heading = u'Updating File %s' % c.file.id
        c.filledForm = htmlfill.render(form, defaults=values, errors=errors)
        page = render('/derived/file/update.html')

    return page
Пример #54
0
 def index(self):
     keyword_q = meta.Session.query(model.Keyword).order_by(
         model.Keyword.name)
     c.keywords = keyword_q.all()
     syncat_q = meta.Session.query(model.SyntacticCategory).order_by(
         model.SyntacticCategory.name)
     c.syncats = syncat_q.all()
     elicitationMethod_q = meta.Session.query(
         model.ElicitationMethod).order_by(model.ElicitationMethod.name)
     c.elicitationMethods = elicitationMethod_q.all()
     return render('/derived/tag/index.html')
Пример #55
0
def renderAddFile(values=None, errors=None, addUpdate='add'):
    """Function is called by both the add and update actions to create the
    Add File and Update File HTML forms.  The create and save actions can also
    call this function if any errors are present in the input.
    
    """

    # if addUpdate is set to 'update', render update.html instead of add.html
    if addUpdate == 'add':
        form = render('/derived/file/addForm.html')
        c.heading = u'Add a File'
        c.filledForm = htmlfill.render(form, defaults=values, errors=errors)
        page = render('/derived/file/add.html')
    else:
        form = render('/derived/file/updateForm.html')
        c.heading = u'Updating File %s' % c.file.id
        c.filledForm = htmlfill.render(form, defaults=values, errors=errors)
        page = render('/derived/file/update.html')

    return page
Пример #56
0
 def view(self, id):
     """View a BLD File.  Requires a File ID as input."""
     if id is None:
         abort(404)
     file_q = meta.Session.query(model.File)
     try:
         c.file = file_q.get(int(id))
     except ValueError:
         abort(404)
     if c.file is None:
         abort(404)
     return render('/derived/file/view.html')
Пример #57
0
    def createSQLiteDBCopy(self):
        """Create a SQLite3 db file containing all of the data in the MySQL
        database.

        """

        createSQLiteDBCopy.createSQLiteDBCopy()

        session['flash'] = 'SQLite3 copy of database created.'
        session.save()

        return render('/derived/administer/index.html')
Пример #58
0
    def link(self, id):
        """Associate BLD File with id=id to a BLD Form.  The ID of the Form is
        passed via a POST form.  This "ID" may in fact be a comma-separated list
        of Form IDs.

        """

        schema = AssociateFileFormForm()

        values = dict(request.params)
        try:
            result = schema.to_python(dict(request.params), c)
        except Invalid, e:
            c.file = meta.Session.query(model.File).filter_by(id=id).first()
            associateForm = render('/derived/file/associateForm.html')
            errors = variabledecode.variable_encode(e.unpack_errors() or {},
                                                    add_repetitions=False)
            c.associateForm = htmlfill.render(associateForm,
                                              defaults=values,
                                              errors=errors)
            return render('/derived/file/associate.html')
Пример #59
0
 def results(self):
     """Results action uses the filterSearchQuery helper function to build
     a query based on the values entered by the user in the search file."""
     if 'fileSearchValues' in session:
         result = session['fileSearchValues']
         file_q = meta.Session.query(model.File)
         file_q = h.filterSearchQuery(result, file_q, 'File')
     else:
         file_q = meta.Session.query(model.File)
     c.paginator = paginate.Page(
         file_q,
         page=int(request.params.get('page', 1)),
         items_per_page=app_globals.file_items_per_page)
     return render('/derived/file/results.html')