~yeliabmas/sloecode/sloecode-template

« back to all changes in this revision

Viewing changes to sloecode/controllers/wiki.py

  • Committer: Sam Bailey
  • Date: 2012-10-30 03:45:30 UTC
  • Revision ID: yeliabmas@gmail.com-20121030034530-1obbt428wynab8lh
Tidied up most of the page template interfaces.

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
        # Make sure filename doesn't start with a slash
219
219
        if filename[0] == '/':
220
220
            filename = filename[1:]
221
 
        path = save_location + filename
 
221
        save_path = save_location + filename
222
222
 
223
223
        # Check to see if this file exists
224
224
        branch = get_wiki_branch_for_project(project_name)
225
225
        filestore = BranchFileStore(branch.get_bzrlib_branch())
226
226
        resource_factory = ResourceFactory(filestore)
227
 
        resource = resource_factory.get_resource_at_path(path)
 
227
        resource = resource_factory.get_resource_at_path(save_path)
228
228
 
229
229
        #This file already exists.
230
230
        if resource.file_resource is not None:
231
231
            h.flash("This file already exists.")
232
 
            return formencode.htmlfill.render(self.new_file(project_name), defaults=request.params)
 
232
            return formencode.htmlfill.render(self.new_file(project_name, path=path), defaults=request.params)
233
233
 
234
234
        # This is a directory.
235
235
        if resource.dir_resource is not None:
236
236
            h.flash("A directory already exists with this name.")
237
 
            return formencode.htmlfill.render(self.new_file(project_name), defaults=request.params)
 
237
            return formencode.htmlfill.render(self.new_file(project_name, path=path), defaults=request.params)
238
238
 
239
 
        path += '/+save'
 
239
        save_path += '/+save'
240
240
        # Are there any checks that need to be performed on the path???
241
 
        return redirect(h.url(controller='wiki', action='wiki', project_name=project_name, path=path, content=content, description=description))
 
241
        return redirect(h.url(controller='wiki', action='wiki', project_name=project_name, path=save_path, content=content, description=description))
242
242
 
243
 
    def load_template(self, filename):
 
243
    def load_page_template(self, filename):
244
244
        """Loads a template in json format."""
245
245
        template = Template.get_one(name=filename)
246
246
        if template: