allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 05/07: [#8368] style improvements
Date Mon, 14 Jun 2021 20:51:41 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8368
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 974224974da8c9b63dc4d7b30ddb3d31fb9902a1
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
AuthorDate: Mon Jun 14 13:40:59 2021 -0400

    [#8368] style improvements
---
 ForgeFiles/forgefiles/files_main.py                |  3 +--
 ForgeFiles/forgefiles/nf/files/js/create_folder.js | 29 +++++++++++-----------
 ForgeFiles/forgefiles/nf/files/js/delete.js        | 17 ++++++-------
 ForgeFiles/forgefiles/nf/files/js/upload_files.js  | 29 +++++++++++-----------
 .../forgefiles/tests/functional/test_root.py       |  2 +-
 ForgeFiles/forgefiles/tests/model/test_files.py    |  5 ++--
 ForgeFiles/setup.cfg                               | 13 ++++++++++
 7 files changed, 53 insertions(+), 45 deletions(-)

diff --git a/ForgeFiles/forgefiles/files_main.py b/ForgeFiles/forgefiles/files_main.py
index 7a48c11..38a7c7d 100755
--- a/ForgeFiles/forgefiles/files_main.py
+++ b/ForgeFiles/forgefiles/files_main.py
@@ -381,8 +381,7 @@ class FilesController(BaseController):
             require_access(folder_object, 'publish')
             folder_object.published = True
             folder_object.remarks = remarks
-            mailbox_object = M.Mailbox.query.find({
-                'app_config_id': c.app.config._id, 'app_config_id': c.app.config._id}).all()
+            mailbox_object = M.Mailbox.query.find({'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
diff --git a/ForgeFiles/forgefiles/nf/files/js/create_folder.js b/ForgeFiles/forgefiles/nf/files/js/create_folder.js
index f293612..ec9a8e3 100644
--- a/ForgeFiles/forgefiles/nf/files/js/create_folder.js
+++ b/ForgeFiles/forgefiles/nf/files/js/create_folder.js
@@ -39,25 +39,24 @@ function validateFolderForm(){
  }
 
 function validateName(folder_name){
-
     var error = $('#error_message');
     var regular_exp = new RegExp("^[a-zA-Z0-9_ +.,=#~@!()\\[\\]-]+$");
     var validation_msg;
-    if(folder_name.length===0){validation_msg="Please enter folder name."}
-    else{
-        if(folder_name.slice(0,1)==="."){
-            validation_msg='Folder name cannot start with ".".'}
-        else{
-            if(folder_name.slice(0,1)===" "){
-                validation_msg="Folder name cannot start with a space."}
-            else{
-                if(folder_name.slice(-1)===" "){
-                    validation_msg="Folder name cannot end with a space."}
-                else{if(!regular_exp.test(folder_name)){validation_msg='Folder name cannot
contain characters like ($/\"%^&*`|?<>:;).'}
-                else{validation_msg=true}}}}}
-    
-    return validation_msg;
+    if (folder_name.length === 0) {
+        validation_msg = "Please enter folder name.";
+    } else if (folder_name.slice(0, 1) === ".") {
+        validation_msg = 'Folder name cannot start with ".".';
+    } else if (folder_name.slice(0, 1) === " ") {
+        validation_msg = "Folder name cannot start with a space.";
+    } else if (folder_name.slice(-1) === " ") {
+        validation_msg = "Folder name cannot end with a space.";
+    } else if (!regular_exp.test(folder_name)) {
+        validation_msg = 'Folder name cannot contain characters like ($/\"%^&*`|?<>:;).';
+    } else {
+        validation_msg = true;
     }
+    return validation_msg;
+}
 
 $('#folder_id').keyup(function(){
     var folder_name = $('#folder_id').val();
diff --git a/ForgeFiles/forgefiles/nf/files/js/delete.js b/ForgeFiles/forgefiles/nf/files/js/delete.js
index f53b679..20e2150 100644
--- a/ForgeFiles/forgefiles/nf/files/js/delete.js
+++ b/ForgeFiles/forgefiles/nf/files/js/delete.js
@@ -19,15 +19,14 @@
 
 $('#admin_modal_title').hide();
 
- function ConfirmDeleteFolder(){
-      var obj_id = document.getElementById('delete_id');
-      var confirm_delete = $(obj_id).val();
-      var error = $('#error_message');
-      if((confirm_delete === "DELETE")){
+function ConfirmDeleteFolder() {
+    var obj_id = document.getElementById('delete_id');
+    var confirm_delete = $(obj_id).val();
+    var error = $('#error_message');
+    if (confirm_delete === "DELETE") {
         return true;
-        }
-      else{
+    } else {
         $(error).text('You must confirm with the word DELETE');
         return false;
-      }
-     }
+    }
+}
diff --git a/ForgeFiles/forgefiles/nf/files/js/upload_files.js b/ForgeFiles/forgefiles/nf/files/js/upload_files.js
index c00c582..268f016 100644
--- a/ForgeFiles/forgefiles/nf/files/js/upload_files.js
+++ b/ForgeFiles/forgefiles/nf/files/js/upload_files.js
@@ -19,18 +19,17 @@
 
 $('#admin_modal_title').hide();
 
- function validateFileForm(){
-     var file_input = document.getElementById('file_input');
-     var file_path = file_input.value.split('\\').pop();
-     var filename = $('#filename');
-     var file_val = $(file_input).val();
-     var error = $('#error_message');
-     if (file_val.length === 0){
-         $(error).text('Please upload a file');
-         return false;
-         }
-     else{
-         $(filename).val(file_path);
-         return true;
-         }
- }
+function validateFileForm() {
+    var file_input = document.getElementById('file_input');
+    var file_path = file_input.value.split('\\').pop();
+    var filename = $('#filename');
+    var file_val = $(file_input).val();
+    var error = $('#error_message');
+    if (file_val.length === 0) {
+        $(error).text('Please upload a file');
+        return false;
+    } else {
+        $(filename).val(file_path);
+        return true;
+    }
+}
diff --git a/ForgeFiles/forgefiles/tests/functional/test_root.py b/ForgeFiles/forgefiles/tests/functional/test_root.py
index fb1f41e..3a3be7b 100644
--- a/ForgeFiles/forgefiles/tests/functional/test_root.py
+++ b/ForgeFiles/forgefiles/tests/functional/test_root.py
@@ -53,7 +53,7 @@ class TestFiles(TestController):
         path = dir.write('myfile.txt', b'Testing Upload')
         with open(path, 'rb') as f:
             file_upload = [('file_upload', 'myfile.txt', f.read())]
-            filename_dict = {'filename':'myfile.txt'}
+            filename_dict = {'filename': 'myfile.txt'}
             file_object = self.app.post('/p/test/files/upload_file', filename_dict, upload_files=file_upload)
         dir.cleanup()
         assert file_object is not None
diff --git a/ForgeFiles/forgefiles/tests/model/test_files.py b/ForgeFiles/forgefiles/tests/model/test_files.py
index 5e3e3e0..cb43f28 100644
--- a/ForgeFiles/forgefiles/tests/model/test_files.py
+++ b/ForgeFiles/forgefiles/tests/model/test_files.py
@@ -26,12 +26,11 @@ from forgefiles.model.files import UploadFolder
 from forgefiles.model.files import UploadFiles
 
 
-
 class TestUpload(FilesTestWithModel):
     ''' Test class for UploadFolder & uploadFiles model'''
 
     def test_upload_folder(self):
-        '''Creates an object of the UploadFolder Collction and tests its fields'''
+        '''Creates an object of the UploadFolder Collection and tests its fields'''
         upload_folder = UploadFolder
         upload_folder.folder_name = 'testFolder'
         upload_folder.published = True
@@ -43,7 +42,7 @@ class TestUpload(FilesTestWithModel):
         assert_false(upload_folder.disabled)
 
     def test_upload_file(self):
-        '''Creates an object of the UploadFiles Collction and tests its fields'''
+        '''Creates an object of the UploadFiles Collection and tests its fields'''
 
         upload_file = UploadFiles
         upload_file.filename = 'testFile'
diff --git a/ForgeFiles/setup.cfg b/ForgeFiles/setup.cfg
new file mode 100644
index 0000000..1181fa3
--- /dev/null
+++ b/ForgeFiles/setup.cfg
@@ -0,0 +1,13 @@
+[pep8]
+max-line-length = 119
+
+[flake8]
+max-line-length = 119
+
+[egg_info]
+tag_build = dev0
+
+[coverage:run]
+parallel=true
+concurrency=multiprocessing
+source=../Allura/allura,forgefiles
\ No newline at end of file

Mime
View raw message