This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 0587720bf1bb6e5a8a0ed673aeebe77bc38be91b Author: Sanskriti Mohapatra <[email protected]> AuthorDate: Thu Apr 15 12:35:36 2021 +0530 [#8368] Implementation of review points. --- Allura/allura/templates/jinja_master/master.html | 9 +- Allura/allura/templates/jinja_master/nav_menu.html | 11 ++- ForgeFiles/forgefiles/files_main.py | 96 ++++++++++++---------- ForgeFiles/forgefiles/model/files.py | 61 ++++---------- ForgeFiles/forgefiles/nf/files/js/files.js | 7 +- ForgeFiles/forgefiles/templates/files.html | 11 +-- .../forgefiles/tests/functional/test_root.py | 2 - ForgeFiles/forgefiles/tests/model/test_files.py | 3 +- 8 files changed, 90 insertions(+), 110 deletions(-) diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html index 101ee23..3e8b0d8 100644 --- a/Allura/allura/templates/jinja_master/master.html +++ b/Allura/allura/templates/jinja_master/master.html @@ -44,7 +44,9 @@ {% do g.register_forge_js('js/memorable.js') %} {% do g.resource_manager.register_widgets(c) %} - +{% if c.project %} +{% set files_appconfig = c.project.app_config_by_tool_type('files') %} +{% endif %} {# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ #} <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> @@ -201,9 +203,10 @@ }); +{% if files_appconfig %} $(document).ready(function(){ $.ajax({ - url:'/p/{{c.project.shortname}}/files/project_file/', + url:'{{ files_appconfig.url() }}project_file/', type:'GET', success: function(res){ var count = parseInt(res); @@ -215,8 +218,8 @@ $(document).ready(function(){ } } }); - }); +{% endif %} </script> </body> diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html index 4b8ac26..1d754f6 100644 --- a/Allura/allura/templates/jinja_master/nav_menu.html +++ b/Allura/allura/templates/jinja_master/nav_menu.html @@ -19,6 +19,11 @@ {% import 'allura:templates/jinja_master/lib.html' as lib with context %} {% import g.theme.jinja_macros as theme_macros with context %} {% set n = c.project.neighborhood %} + +{% if c.project %} +{% set files_appconfig = c.project.app_config_by_tool_type('files') %} +{% endif %} + {% if not c.project or (n.neighborhood_project == c.project and not n.show_title) %} <div id="nav_menu_missing"></div> {% else %} @@ -40,9 +45,11 @@ {%- endif -%} </a> </h1> - <a href="/p/{{c.project.shortname}}/files/download_file?app_url={{c.app.url}}" > + {% if files_appconfig %} + <a href="{{ files_appconfig.url() }}download_file" > <button class="btn-home btn-danger" id="download_button" >Download</button> </a> + {% endif %} {% set status = c.project.troves_by_type('developmentstatus')|sort(attribute='fullname') %} {% set status = status[-1] %} {% if status and status.shortname not in ['production', 'mature'] %} @@ -96,4 +103,4 @@ function getStars(ratings) { } </script> -{% endif %} \ No newline at end of file +{% endif %} diff --git a/ForgeFiles/forgefiles/files_main.py b/ForgeFiles/forgefiles/files_main.py index 2b378bf..5f32e56 100755 --- a/ForgeFiles/forgefiles/files_main.py +++ b/ForgeFiles/forgefiles/files_main.py @@ -1,5 +1,3 @@ -'''This is the main controller module for the Files Plugin.''' - # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -17,8 +15,7 @@ # specific language governing permissions and limitations # under the License. - -# !/bin/python +'''This is the main controller module for the Files Plugin.''' from __future__ import unicode_literals from __future__ import absolute_import @@ -35,6 +32,7 @@ from allura.app import Application from allura.controllers import BaseController from allura.lib.decorators import require_post from allura.lib.widgets.subscriptions import SubscribeForm +from allura.lib.security import require_access from allura import model as M from allura.controllers import attachments as att from allura import version @@ -104,19 +102,23 @@ def get_parent_folders(linked_file_object=None): class FilesController(BaseController): """Root controller for the Files Application""" + def _check_security(self): + require_access(c.app, 'read') + @expose('jinja:forgefiles:templates/files.html') def index(self): '''Index method for the Root controller''' + require_access(c.app, 'read') folder_object = None file_object = None - upload_object = Upload.query.get(project_id=c.project._id) + upload_object = Upload.query.get(app_config_id=c.app.config._id) self.attachment = AttachmentsController(upload_object) - file_objects = UploadFiles.query.find({'project_id': c.project._id, 'parent_folder_id': None}) + file_objects = UploadFiles.query.find({'app_config_id': c.app.config._id, 'parent_folder_id': None}) file_objects = file_objects.sort([('created_date', -1)]).all() - folder_objects = UploadFolder.query.find({'project_id': c.project._id, 'parent_folder_id': None}) + folder_objects = UploadFolder.query.find({'app_config_id': c.app.config._id, 'parent_folder_id': None}) folder_objects = folder_objects.sort([('created_date', -1)]).all() if c.user in c.project.admins(): M.Mailbox.subscribe(type='direct') @@ -126,9 +128,8 @@ class FilesController(BaseController): subscribed = M.Mailbox.subscribed() else: subscribed = False - file_object = UploadFiles.query.get(project_id=c.project._id, linked_to_download=True) + file_object = UploadFiles.query.get(app_config_id=c.app.config._id, linked_to_download=True) parents = get_parent_folders(linked_file_object=file_object) - return dict(file_objects=file_objects, folder_objects=folder_objects, folder_object=folder_object, file_object=file_object, subscribed=subscribed, parents=parents) @@ -153,10 +154,11 @@ class FilesController(BaseController): '''Controller method for creating a folder. The folder is stored in UploadFolder collection''' + require_access(c.app, 'create') parent_folder_id, parent_folder, url = self.get_parent_folder_url(parent_folder_id) if folder_name: folder_object = UploadFolder.query.find({ - 'project_id': c.project._id, 'folder_name': folder_name, + 'app_config_id': c.app.config._id, 'folder_name': folder_name, 'parent_folder_id': parent_folder_id}).first() if folder_object: flash('Folder with the same name already exists!') @@ -179,16 +181,17 @@ class FilesController(BaseController): '''Controller method for creating a folder. The folder is stored in UploadFolder collection''' + require_access(c.app, 'create') parent_folder_id, parent_folder, url = self.get_parent_folder_url(parent_folder_id) if file_upload is not None: file_object = UploadFiles.query.find({ - 'project_id': c.project._id, 'filename': filename, + 'app_config_id': c.app.config._id, 'filename': filename, 'parent_folder_id': parent_folder_id}).first() if file_object: flash('File with the same name already exists!') else: upload_object = Upload( - project_id=c.project._id, filename=filename, filetype=file_upload.type) + app_config_id=c.app.config._id, filename=filename, filetype=file_upload.type) attach_object = upload_object.attach( filename, file_upload.file, parent_folder_id=parent_folder_id) if attach_object.parent_folder: @@ -212,10 +215,12 @@ class FilesController(BaseController): '''Controller method to delete a file''' file_object = UploadFiles.query.get(_id=ObjectId(file_id)) + upload_object = Upload.query.get(_id=file_object.artifact_id) file_name = file_object.filename transient_actor = TransientActor(activity_name=file_name) url = c.app.url if file_id is not None: + require_access(upload_object, 'delete') self.delete_file_from_db(file_id=file_id) parent_folder = file_object.parent_folder if parent_folder: @@ -225,7 +230,6 @@ class FilesController(BaseController): flash('File is not deleted') g.director.create_activity( c.user, 'deleted the file', transient_actor, related_nodes=[c.project]) - M.main_orm_session.flush() return redirect(url) def delete_file_from_db(self, file_id=None): @@ -241,11 +245,11 @@ class FilesController(BaseController): '''This method is called recursively to delete folder in a hierarchy''' sub_file_objects = UploadFiles.query.find(dict({ - 'project_id': c.project._id, 'parent_folder_id': ObjectId(folder_id)})).all() + 'app_config_id': c.app.config._id, 'parent_folder_id': ObjectId(folder_id)})).all() for file_object in sub_file_objects: self.delete_file_from_db(file_id=file_object._id) sub_folder_objects = UploadFolder.query.find({ - 'project_id': c.project._id, 'parent_folder_id': ObjectId(folder_id)}).all() + 'app_config_id': c.app.config._id, 'parent_folder_id': ObjectId(folder_id)}).all() for folder_object in sub_folder_objects: self.delete_folder_recursively(folder_object._id) UploadFolder.query.remove(dict({'_id': ObjectId(folder_id)})) @@ -262,6 +266,7 @@ class FilesController(BaseController): transient_actor = TransientActor(activity_name=folder_name) url = c.app.url if folder_id is not None: + require_access(folder_object, 'delete') self.delete_folder_recursively(folder_id) if folder_object.parent_folder: url = folder_object.parent_folder.url() @@ -270,28 +275,29 @@ class FilesController(BaseController): flash('Folder is not deleted') g.director.create_activity( c.user, 'deleted the folder', transient_actor, related_nodes=[c.project]) - M.main_orm_session.flush() return redirect(url) + @without_trailing_slash + @require_post() @expose() def link_file(self, file_id=None, status=None): '''Controller method to link a file to the download button''' + + linkable_file_object = UploadFiles.query.get(_id=ObjectId(file_id)) + upload_object = Upload.query.get(_id=linkable_file_object.artifact_id) + require_access(upload_object, 'link') if status == 'False': - linkable_file_object = UploadFiles.query.get(_id=ObjectId(file_id)) linkable_file_object.linked_to_download = False - M.main_orm_session.flush() else: - file_objects = UploadFiles.query.find({'project_id': c.project._id}).all() + file_objects = UploadFiles.query.find({'app_config_id': c.app.config._id}).all() for file_object in file_objects: if file_object.linked_to_download: file_object.linked_to_download = False - linkable_file_object = UploadFiles.query.get(_id=ObjectId(file_id)) linkable_file_object.linked_to_download = True - M.main_orm_session.flush() @expose() - def download_file(self, filename=None, app_url=None): + def download_file(self, filename=None): '''Controller method to download a file''' @@ -299,11 +305,11 @@ class FilesController(BaseController): request_path = request.path.split(c.app.url)[-1].rstrip('/') request_path = unquote(request_path) linked_file_object = UploadFiles.query.find({ - 'project_id': c.project._id, 'filename': filename, 'path': request_path}).first() + 'app_config_id': c.app.config._id, 'filename': filename, 'path': request_path}).first() upload_object = Upload.query.find({'_id': linked_file_object.artifact_id}).first() else: linked_file_object = UploadFiles.query.find({ - 'project_id': c.project._id, 'linked_to_download': True}).first() + 'app_config_id': c.app.config._id, 'linked_to_download': True}).first() if linked_file_object: upload_object = Upload.query.find({'_id': linked_file_object.artifact_id}).first() else: @@ -311,21 +317,15 @@ class FilesController(BaseController): if linked_file_object: try: wrapper = upload_object.attachments[::-1] - data = wrapper - response.headers['Content-Type'] = 'application/octet' - response.headers['Content-Length'] = len(data) - response.headers['Pragma'] = 'public' - response.headers['Cache-Control'] = 'max-age=0' - requested_filename = linked_file_object.filename - response.headers['Content-Disposition'] = 'attachment; filename="%s"' % (requested_filename) + from allura.lib.utils import serve_file M.Mailbox.subscribe(type='direct') - return linked_file_object.serve(embed=True) + return linked_file_object.serve(embed=False) except Exception as e: log.exception('%s error to download the file', e) else: data = 'No artifact available' flash('No artifact available') - return redirect(app_url) + return redirect(c.app.url) @require_post() @expose() @@ -336,13 +336,13 @@ class FilesController(BaseController): url = c.app.url folder_object = UploadFolder.query.get(_id=ObjectId(folder_id)) if folder_object: + require_access(folder_object, 'update') folder_object.folder_name = folder_name flash("Folder name edited successfully") if folder_object.parent_folder: url = folder_object.parent_folder.url() else: flash("Folder name not edited") - M.main_orm_session.flush() redirect(url) @require_post() @@ -355,6 +355,7 @@ class FilesController(BaseController): file_object = UploadFiles.query.get(_id=ObjectId(file_id)) upload_object = Upload.query.get(_id=file_object.artifact_id) if file_object: + require_access(upload_object, 'update') upload_object.filename = file_name file_object.filename = file_name flash("File name edited successfully") @@ -362,7 +363,6 @@ class FilesController(BaseController): url = file_object.parent_folder.url() else: flash("File not edited") - M.main_orm_session.flush() return redirect(url) @require_post() @@ -374,10 +374,11 @@ class FilesController(BaseController): folder_object = UploadFolder.query.get(_id=ObjectId(folder_id)) url = c.app.url if folder_object: + require_access(folder_object, 'publish') folder_object.published = True folder_object.remarks = remarks mailbox_object = M.Mailbox.query.find({ - 'project_id': c.project._id, 'app_config_id': c.app.config._id}).all() + 'app_config_id': c.app.config._id, 'app_config_id': c.app.config._id}).all() user_ids = [i.user_id for i in mailbox_object] admins = [i._id for i in c.project.admins()] user_ids += admins @@ -419,7 +420,6 @@ class FilesController(BaseController): '''Controller method to disable the folder.''' folder_object = UploadFolder.query.get(_id=ObjectId(folder_id)) - if status == 'True': disable_status = True text = 'disabled' @@ -427,6 +427,7 @@ class FilesController(BaseController): disable_status = False text = 'enabled' if folder_object: + require_access(folder_object, 'disable') folder_object.disabled = disable_status '''Disabling Child folders & files of the current folder ''' @@ -438,7 +439,6 @@ class FilesController(BaseController): child_file_object = UploadFiles.query.get(_id=ObjectId(child_file_id)) if child_file_object: child_file_object.disabled = disable_status - M.main_orm_session.flush() flash('Folder %s successfully' % (text)) else: flash('No folder exists') @@ -450,6 +450,7 @@ class FilesController(BaseController): '''Controller method to disable the file.''' file_object = UploadFiles.query.get(_id=ObjectId(file_id)) + upload_object = Upload.query.get(_id=file_object.artifact_id) if status == 'True': disable_status = True text = 'disabled' @@ -457,6 +458,7 @@ class FilesController(BaseController): disable_status = False text = 'enabled' if file_object: + require_access(upload_object, 'disable') file_object.disabled = disable_status flash('File %s successfully' % (text)) else: @@ -465,7 +467,7 @@ class FilesController(BaseController): @expose() def project_file(self): files_count = UploadFiles.query.find({ - 'project_id': c.project._id, 'linked_to_download': True, 'disabled': False}).count() + 'app_config_id': c.app.config._id, 'linked_to_download': True, 'disabled': False}).count() return str(files_count) @expose('json:') @@ -521,7 +523,7 @@ class FilesController(BaseController): @expose('jinja:forgefiles:templates/publish_folder.html') def get_publishable_folder(self, folder_id=None): '''Returns the status and folder object if the folder can be published or not''' - linked_file_object = UploadFiles.query.get(project_id=c.project._id, linked_to_download=True, disabled=False) + linked_file_object = UploadFiles.query.get(app_config_id=c.app.config._id, linked_to_download=True, disabled=False) parent_folders = get_parent_folders(linked_file_object=linked_file_object) if folder_id: folder_object = UploadFolder.query.get(_id=ObjectId(folder_id)) @@ -575,9 +577,9 @@ class IndividualFilesController(BaseController): path = unquote(path) arg = unquote(arg) self.folder_object = UploadFolder.query.find({ - 'project_id': ObjectId(c.project._id), 'folder_name': arg, 'path': path}).first() + 'app_config_id': ObjectId(c.app.config._id), 'folder_name': arg, 'path': path}).first() self.file_object = UploadFiles.query.find({ - 'project_id': ObjectId(c.project._id), 'filename': arg, 'path': path}).first() + 'app_config_id': ObjectId(c.app.config._id), 'filename': arg, 'path': path}).first() methods = ('create_folder', 'upload_file', 'delete_file', 'delete_folder', 'subscribe') if (not self.folder_object) and (not self.file_object) and (arg not in methods): log.exception('No Folder/File object found') @@ -585,19 +587,23 @@ class IndividualFilesController(BaseController): else: pass + def _check_security(self): + require_access(c.app, 'read') + @expose('jinja:forgefiles:templates/files.html') @with_trailing_slash def index(self): ''' Index method of individual folder/file objects''' + require_access(c.app, 'read') folder_objects = None file_objects = None folder_path, urls = '', '' if self.folder_object: folder_objects = UploadFolder.query.find({ - 'project_id': c.project._id, 'parent_folder_id': self.folder_object._id}) + 'app_config_id': c.app.config._id, 'parent_folder_id': self.folder_object._id}) folder_objects = folder_objects.sort([('created_date', -1)]).all() file_objects = UploadFiles.query.find({ - 'project_id': c.project._id, 'parent_folder_id': self.folder_object._id}) + 'app_config_id': c.app.config._id, 'parent_folder_id': self.folder_object._id}) file_objects = file_objects.sort([('created_date', -1)]).all() folder_path, urls = folder_breadcrumbs(folder_object=self.folder_object) elif self.file_object: @@ -610,7 +616,7 @@ class IndividualFilesController(BaseController): subscribed = M.Mailbox.subscribed() else: subscribed = False - file_object = UploadFiles.query.get(project_id=c.project._id, linked_to_download=True) + file_object = UploadFiles.query.get(app_config_id=c.app.config._id, linked_to_download=True) parents = get_parent_folders(linked_file_object=file_object) return dict(folder_objects=folder_objects, diff --git a/ForgeFiles/forgefiles/model/files.py b/ForgeFiles/forgefiles/model/files.py index c4c7bb9..ecfef2b 100755 --- a/ForgeFiles/forgefiles/model/files.py +++ b/ForgeFiles/forgefiles/model/files.py @@ -1,5 +1,4 @@ -''' This is the Collection module for the Files plugin. Upload, UploadFolder & UploadFile are the collections''' -# Licensed to the Apache Software Foundation (ASF) under one +# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file @@ -16,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +''' This is the Collection module for the Files plugin. +Upload, UploadFolder & UploadFile are the collections''' from __future__ import unicode_literals from __future__ import absolute_import @@ -47,6 +48,7 @@ class Upload(VersionedArtifact, ActivityObject): class __mongometa__: name = 'upload' session = project_orm_session + type_s = 'Upload' _id = FieldProperty(S.ObjectId) filename = FieldProperty(str) @@ -83,7 +85,7 @@ class UploadFolder(VersionedArtifact, ActivityObject): project_id = ForeignIdProperty('Project', if_missing=lambda: c.project._id) parent_folder_id = ForeignIdProperty('UploadFolder') created_date = FieldProperty(datetime, if_missing=datetime.utcnow) - author = ForeignIdProperty('User', if_missing=lambda: c.user._id) + author_id = ForeignIdProperty('User', if_missing=lambda: c.user._id) parent_folder = RelationProperty('UploadFolder', via='parent_folder_id') project = RelationProperty('Project', via='project_id') path = FieldProperty(str) @@ -92,13 +94,7 @@ class UploadFolder(VersionedArtifact, ActivityObject): disabled = FieldProperty(bool, if_missing=False) folder_ids = FieldProperty([str]) file_ids = FieldProperty([str]) - - def created_by(self): - - '''Returns the user object of the admin who creaated the folder ''' - - user_obj = User.query.find({'_id': self.author}).first() - return user_obj + author = RelationProperty(User, via='author_id') def url(self): parent_folder = self.parent_folder @@ -140,10 +136,15 @@ class UploadFiles(File): thumbnail_size = (255, 255) ArtifactType = Upload + class __mongometa__: name = 'upload_files' session = project_orm_session - indexes = ['artifact_id', 'app_config_id'] + indexes = [ + ('app_config_id', 'parent_folder_id', 'filename'), + ('app_config_id', 'linked_to_download', 'disabled'), + ('app_config_id', 'filename', 'path'), + ] def before_save(data): _session = artifact_orm_session._get() @@ -159,29 +160,12 @@ class UploadFiles(File): parent_folder_id = ForeignIdProperty('UploadFolder') created_date = FieldProperty(datetime, if_missing=datetime.utcnow) mod_date = FieldProperty(datetime, if_missing=datetime.utcnow) - author = AlluraUserProperty(if_missing=lambda: c.user._id) + author_id = AlluraUserProperty(if_missing=lambda: c.user._id) parent_folder = RelationProperty('UploadFolder', via='parent_folder_id') linked_to_download = FieldProperty(bool, if_missing=False) path = FieldProperty(str) disabled = FieldProperty(bool, if_missing=False) - - @property - def file_size(self): - - '''Returns the size of the file''' - - size = self.length - one_gb = 1000000000 - one_mb = 1000000 - one_kb = 1000 - if size > one_gb: - return "{0:.2f} GB".format(float(size)/one_gb) - elif size > one_mb: - return "{0:.2f} MB".format(float(size)/one_mb) - elif size > one_kb: - return "{0:.2f} KB".format(float(size)/one_kb) - else: - return "{} B".format(size) + author = RelationProperty(User, via='author_id') @property def artifact(self): @@ -190,13 +174,6 @@ class UploadFiles(File): return self.ArtifactType.query.get(_id=self.artifact_id) - def uploaded_by(self): - - '''Returns the user object of the admin who uploads the file''' - - user_obj = User.query.find({'_id': self.author}).first() - return user_obj - def url(self): '''Returns the URL of the uploaded file''' @@ -225,16 +202,6 @@ class UploadFiles(File): return (self.filename, h.really_unicode(obj_content)) return None, None - def is_embedded(self): - from tg import request - return self.filename in request.environ.get('allura.macro.att_embedded', []) - - @classmethod - def metadata_for(cls, artifact): - return dict( - artifact_id=artifact._id, - app_config_id=artifact.app_config_id) - @classmethod def save_attachment(cls, filename, fp, content_type=None, **kwargs): filename = h.really_unicode(filename) diff --git a/ForgeFiles/forgefiles/nf/files/js/files.js b/ForgeFiles/forgefiles/nf/files/js/files.js index 53a1684..afa8ae0 100644 --- a/ForgeFiles/forgefiles/nf/files/js/files.js +++ b/ForgeFiles/forgefiles/nf/files/js/files.js @@ -24,6 +24,7 @@ function removeModalContent(){ $('#error_message_delete_folder').remove(); } +var cval = $.cookie('_session_id'); function ConfirmDisableFolder(folderID,status,parent_status,url) { @@ -41,7 +42,7 @@ function removeModalContent(){ var disable_status = 'False'; } if (confirm_resp){ - $.post(url, {'folder_id':folderID, 'status':disable_status}, function() { + $.post(url, {'folder_id':folderID, 'status':disable_status, _session_id:cval}, function() { location.reload(); }); } @@ -66,7 +67,7 @@ function removeModalContent(){ var disable_status = 'False'; } if (confirm_resp){ - $.post(url, {'file_id':fileID, 'status':disable_status}, function() { + $.post(url, {'file_id':fileID, 'status':disable_status, _session_id:cval}, function() { location.reload(); }); } @@ -86,7 +87,7 @@ function removeModalContent(){ var confirm_resp = confirm("Are you sure you want to link to the Downloads?"); var link_status = 'True'; } - $.post(url, {'file_id':fileID, 'status':link_status}, function() { + $.post(url, {'file_id':fileID, 'status':link_status, _session_id:cval}, function() { location.reload(); }) } diff --git a/ForgeFiles/forgefiles/templates/files.html b/ForgeFiles/forgefiles/templates/files.html index 91a0d41..af002b9 100755 --- a/ForgeFiles/forgefiles/templates/files.html +++ b/ForgeFiles/forgefiles/templates/files.html @@ -55,7 +55,6 @@ Files {% if folder_object %} - {{path_links(folder_path.split('/'), urls)}} {% e {% block content %} -{% if not c.user.is_anonymous() %} <div class="main_div"> @@ -108,7 +107,7 @@ Files {% if folder_object %} - {{path_links(folder_path.split('/'), urls)}} {% e </td> <td>{{lib.abbr_date(folder.created_date)}}</td> <td></td> - <td title="{{folder.created_by().display_name}}">{{folder.created_by().display_name|truncate(30)}}</td> + <td title="{{folder.author.display_name}}">{{folder.author.display_name|truncate(30)}}</td> {% if h.has_access(c.project, 'admin')() %} <td> <div class="folder_actions"> @@ -140,8 +139,8 @@ Files {% if folder_object %} - {{path_links(folder_path.split('/'), urls)}} {% e </td> <td>{{lib.abbr_date(file.created_date)}}</td> - <td>{{file.file_size}}</td> - <td title="{{file.uploaded_by().display_name}}">{{file.uploaded_by().display_name|truncate(30)}}</td> + <td>{{h.do_filesizeformat(file.length)}}</td> + <td title="{{file.author.display_name}}">{{file.author.display_name|truncate(30)}}</td> {% if h.has_access(c.project, 'admin')() %} <td> <div class="file_actions"> @@ -157,6 +156,7 @@ Files {% if folder_object %} - {{path_links(folder_path.split('/'), urls)}} {% e {% endif %} </tr> {% endfor %} + {{ lib.csrf_token() }} </tbody> </table> {% else %} @@ -178,9 +178,6 @@ Files {% if folder_object %} - {{path_links(folder_path.split('/'), urls)}} {% e </div> -{% else %} - <p> Please login to upload a project file </p> -{% endif %} {% endblock %} diff --git a/ForgeFiles/forgefiles/tests/functional/test_root.py b/ForgeFiles/forgefiles/tests/functional/test_root.py index fd3b057..fb1f41e 100644 --- a/ForgeFiles/forgefiles/tests/functional/test_root.py +++ b/ForgeFiles/forgefiles/tests/functional/test_root.py @@ -16,7 +16,6 @@ # under the License. from __future__ import unicode_literals from __future__ import absolute_import -from __future__ import print_function from tg import tmpl_context as c from nose.tools import assert_true,assert_not_equal,assert_equals @@ -81,7 +80,6 @@ class TestFiles(TestController): data1 = {'folder_id': str(folder_object._id), 'remarks': 'Publishing new Version'} self.app.post('/p/test/files/publish_folder', data1) resp = self.app.get('/files/') - print((folder_object.published)) assert_equals(folder_object.published, True) def test_link_file(self): diff --git a/ForgeFiles/forgefiles/tests/model/test_files.py b/ForgeFiles/forgefiles/tests/model/test_files.py index 9c236ec..5e3e3e0 100644 --- a/ForgeFiles/forgefiles/tests/model/test_files.py +++ b/ForgeFiles/forgefiles/tests/model/test_files.py @@ -1,4 +1,3 @@ -'''This module is added for testing the files model ''' # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information @@ -16,6 +15,8 @@ # specific language governing permissions and limitations # under the License. +'''This module is added for testing the files model ''' + from __future__ import unicode_literals from __future__ import absolute_import from nose.tools import assert_equal, assert_true, assert_false
