Skip to content

Commit

Permalink
Merge pull request #151 from ctsit/bugfix/grid
Browse files Browse the repository at this point in the history
Bugfix/grid
  • Loading branch information
PFWhite authored Jul 11, 2017
2 parents 243a041 + 31cfe89 commit 5ca3b0e
Show file tree
Hide file tree
Showing 36 changed files with 3,167 additions and 159 deletions.
2 changes: 2 additions & 0 deletions app/db/005/downgrade.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- remove file type column
ALTER TABLE SubjectFile DROP sfFileType;
3 changes: 3 additions & 0 deletions app/db/005/upgrade.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-- ensure there will be no duplicates user / user role pairs
ALTER TABLE SubjectFile
ADD sfFileType varchar(255) NOT NULL;
Empty file modified app/deploy/deploy.sh
100755 → 100644
Empty file.
6 changes: 4 additions & 2 deletions app/deploy/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,8 @@ def mysql_create_tables():
'002/upgrade.sql',
'002/data.sql',
'003/upgrade.sql',
'004/upgrade.sql']
'004/upgrade.sql',
'005/upgrade.sql' ]

with lcd('../db/'):
for sql in files:
Expand All @@ -377,7 +378,8 @@ def mysql_drop_tables():
abort(colors.red("Unable to drop tables in database '%(db_name)s'."
"The database does not exist" % env))

files = ['004/downgrade.sql',
files = ['005/downgrade.sql',
'004/downgrade.sql',
'003/downgrade.sql',
'002/downgrade.sql',
'001/downgrade.sql']
Expand Down
2 changes: 2 additions & 0 deletions app/fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def init_db():
local('sudo mysql ctsi_dropper_s < db/002/data.sql')
local('sudo mysql ctsi_dropper_s < db/003/upgrade.sql')
local('sudo mysql ctsi_dropper_s < db/004/upgrade.sql')
local('sudo mysql ctsi_dropper_s < db/005/upgrade.sql')


@task
Expand All @@ -82,6 +83,7 @@ def reset_db():
local('sudo mysql ctsi_dropper_s < db/002/data.sql')
local('sudo mysql ctsi_dropper_s < db/003/upgrade.sql')
local('sudo mysql ctsi_dropper_s < db/004/upgrade.sql')
local('sudo mysql ctsi_dropper_s < db/005/upgrade.sql')


@task
Expand Down
7 changes: 3 additions & 4 deletions app/redidropper/models/subject_file_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class SubjectFileEntity(db.Model, CRUDMixin):
file_name = db.Column("sfFileName", db.String(255), nullable=False)
file_check_sum = db.Column("sfFileCheckSum", db.String(32), nullable=False)
file_size = db.Column("sfFileSize", db.String(255), nullable=False)
file_type = db.Column("sfFileType", db.String(255), nullable=False)
uploaded_at = db.Column("sfUploadedAt", db.DateTime, nullable=False,
server_default='0000-00-00 00:00:00')
user_id = db.Column("usrID", db.Integer, db.ForeignKey('User.usrID'),
Expand Down Expand Up @@ -100,12 +101,10 @@ def serialize(self):
'file_name': self.file_name,
'file_check_sum': self.file_check_sum,
'file_size': self.file_size,
'file_type': self.file_type,
'uploaded_at': utils.localize_est_datetime(self.uploaded_at),
'subject_id': self.subject_id,
'event_id': self.event_id,
'user_id': self.user_id,
'user_name': self.user.get_name(),
# 'subject': self.subject.serialize(),
# 'event': self.event.serialize(),
# 'user': self.user.serialize(),
'user_name': self.user.get_name()
}
33 changes: 33 additions & 0 deletions app/redidropper/routes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Goal: Delegate requests to the `/api` path to the appropriate controller
@authors:
Akash Agarwal <agarwala989@gmail.com
Andrei Sura <sura.andrei@gmail.com>
Ruchi Vivek Desai <ruchivdesai@gmail.com>
Sanath Pasumarthy <sanath@ufl.edu>
Expand Down Expand Up @@ -182,7 +183,23 @@ def api_delete_file():
response = utils.jsonify_error({"exception": ret_value})

return response

@app.route('/api/update_fileType', methods=['POST'])
@login_required
def api_update_fileType():
""" Updates the file type """
#get the file from the response
subject_file_id = request.form.get('file_id')
subject_file_type = request.form.get('file_type')
try:
ret_value = file_manager.update_filetype(subject_file_id, subject_file_type)
#app.logger.debug("updated file id: {}".format(subject_file_id))
response = utils.jsonify_success({"file_id": ret_value[0], "file_type": ret_value[1]})

except:
response = utils.jsonify_error({"exception": ret_value})

return response

@app.route("/api/download_file", methods=['POST'])
@login_required
Expand All @@ -200,6 +217,22 @@ def download_file():
LogEntity.file_downloaded(session['uuid'], file_path)
return send_file(file_path, as_attachment=True)

@app.route("/api/all_files_info", methods=['GET'])
@login_required
def all_files_info():
""" Get the list of all uploaded files and their path """
all_files = db.session.query(SubjectFileEntity,EventEntity.redcap_event,SubjectEntity.redcap_id).join(EventEntity).join(SubjectEntity)
return_list = [__build_files_info_json(subject_file,event,subject) for subject_file,event,subject in all_files]
return utils.jsonify_success({'list_of_files' : return_list})

def __build_files_info_json(subject_file,event,subject):
path = subject_file.get_full_path(app.config['REDIDROPPER_UPLOAD_SAVED_DIR'])
file_json = subject_file.serialize()
file_json['path'] = path
file_json['redcap_id'] = subject
file_json['redcap_event'] = event
return file_json

def __extract_user_information(request):
return {
"email": request.form.get('email'),
Expand Down
9 changes: 9 additions & 0 deletions app/redidropper/routes/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def init_from_request(cls):
self.total_size = int(request.form['resumableTotalSize'])
self.uniqueid = request.form['resumableIdentifier']
self.file_name = secure_filename(request.form['resumableFilename'])
self.file_type = request.form['resumableFileType']
self.afile = request.files['file']
self.total_parts = int(request.form['resumableTotalChunks'])
self.redcap_id = request.form['subject_id'] # @TODO: rename
Expand Down Expand Up @@ -73,6 +74,7 @@ def save_file_metadata(fchunk):
file_name=fchunk.file_name,
file_check_sum='pending',
file_size=fchunk.total_size,
file_type=fchunk.file_type,
uploaded_at=added_date,
user_id=current_user.id)
logger.debug("Saved metadata to the db: ".format(subject_file))
Expand Down Expand Up @@ -217,3 +219,10 @@ def delete_file(subject_file_id):
file_entity.delete()
db.session.commit()
return (subject_file_id, file_path)

def update_filetype(subject_file_id, subject_file_type):
""" Updates the type field of the file """
file_entity = SubjectFileEntity.query.filter_by(id=subject_file_id).one()
file_entity.update(file_type=subject_file_type)
db.session.commit()
return (subject_file_id, subject_file_type)
1 change: 1 addition & 0 deletions app/redidropper/routes/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ def check_session_id():
app.logger.error("No row found for sess_id: {}".format(session_id))


@app.route('/index', methods=['POST', 'GET'])
@app.route('/', methods=['POST', 'GET'])
def index():
""" Render the login page"""
Expand Down
5 changes: 2 additions & 3 deletions app/redidropper/routes/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def get_user_links():
the current_user doe not have a role
"""
pages = {
'home': ('index', '1Florida ADRC RED-I Dropper'),
'admin': ('admin', 'Manage Users'),
'logs': ('logs', 'View Logs'),
'dashboard': ('dashboard', 'View Dashboard'),
Expand All @@ -89,10 +90,8 @@ def get_user_links():
'logout': ('logout', 'Logout'),
}
role = get_highest_role()
# print "highest role: {}".format(role)

if role is None:
return []
links = []

if ROLE_ADMIN == role:
links = [pages['admin'],
Expand Down
5 changes: 5 additions & 0 deletions app/redidropper/static/css/dashboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.dash_drop{
width:75px;
height:30px;
padding: 30px 0 0 0;
}
76 changes: 76 additions & 0 deletions app/redidropper/static/css/layout.css
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,87 @@
background-color: #993333;
}

.purple-background {
/*background-color: #5a4d9a;*/
background-color: #4b4080;
}

a.logo-name:hover, a.logo-name:active,
ul.sidebar-nav li a:hover, ul.sidebar-nav li a:active {
color: #FFF !important;
}

.logo_landing {
height: 60px;
}

.navbar-brand {
padding: 0;
}

.navbar {
border: none;
margin-bottom: 0;
}

.btn-default, .btn-primary {
border: none;
}

.form-control:focus {
border-color: #20c8ca;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px rgb(112, 203, 204);
}

h1, h2 {
font-family: 'Montserrat', sans-serif;
}

h1 {
font-size: 38px;
}

h2 {
font-size: 28px;
}

h3 {
font-family: 'Hind', sans-serif;
}

body, p, .form-control, a {
font-family: 'Hind', sans-serif;
font-size: 18px;
}

a, a:visited {
color: #20c8ca;
}

a:hover, a:focus {
text-decoration: underline;
color: #70cbcc;
}

.btn {
background-color: #18a5a6;
color: white;
font-size: 18px;
}

.cta {
background-color: #ffa110;
}

.btn.cta:hover, .btn.cta:focus {
background-color: #f3c173;
}

.btn:hover, .btn:focus {
background-color: #70cbcc;
color: white;
}

th.header {
background-image: url(/static/img/small.gif);
background-repeat: no-repeat;
Expand Down
3 changes: 2 additions & 1 deletion app/redidropper/static/css/parallax.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ This stylesheet and the associated (x)html may be modified in any way to fit you
#home,
#image2,
#image3 {
background: no-repeat center center fixed;
background: no-repeat center top;
display: table;
height: 45vh;
position: relative;
Expand All @@ -44,6 +44,7 @@ This stylesheet and the associated (x)html may be modified in any way to fit you

#home {
background-image: url(/static/img/bottles.jpg);
margin-top: -5px;
}

#image2 {
Expand Down
Loading

0 comments on commit 5ca3b0e

Please sign in to comment.