Skip to content

Commit

Permalink
working on updating exercise page
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilipSnell committed Feb 14, 2022
1 parent 98fcf91 commit 2fcc1d2
Show file tree
Hide file tree
Showing 7 changed files with 347 additions and 83 deletions.
172 changes: 172 additions & 0 deletions static/css/exercises.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@

.exercise-card{
margin-bottom: 20px;
}
.exercise-card-content{
width: 99%;
height: 110px;
border-radius: 10px;
background-color: rgb(95, 95, 95);
position: relative;
vertical-align: middle;
}
.exercise-card-description{
min-height: 20px;
width: 90%;
background-color: rgb(110, 110, 110);
margin-left: 5%;
border-bottom-left-radius: 10px;
border-bottom-right-radius: 10px;
}
.table-wrapper{
margin-top: 10px;
position: relative;
}
.cropImage {
margin-left: -35px;
margin-top: -18px;
/*object-fit: cover;*/
width: 160px;
height: 127.5px;

}
.exercise-image{
display: inline-block;
width: 90px;
height: 90px;
overflow: hidden;
border-radius: 5px;
box-shadow: 0 0 2pt 0.5pt #f4eb49;
display: inline-block;
margin-left:10px;
margin-top:10px;
line-height: 90px;
vertical-align: top;
}
.exercise-title-wrapper{

color: #b9b9b9;
display: inline-block;
font-family: 'Syncopate';
font-style: normal;
font-size: 25px;
width: 45%;
height: 90px;
margin-top: 10px;
padding-left: 20px;
overflow-y: scroll;
vertical-align: top;
}
.exercise-title-wrapper::-webkit-scrollbar{
display: none;
background-color: transparent;
}
.exercise-title{
margin: 0;
position: relative;
top: 50%;
width: 100%;
white-space: wrap;
-ms-transform: translateY(-50%);
transform: translateY(-50%);
}
.exercise-right{
background-color: #a1a1a1;
width: calc(55% - 109px);
height: 110px;
border-radius: 10px;
display: inline-block;
}
.exercise-options{
display: block;
height: 60px;
width: 100%;
padding: 0 !important;
border-radius: 10px;
padding-right: 5px;
}

.exercise-url{
display: block;
height: 40px;
width: calc(100% - 10px);
margin-right: 10px;
margin-bottom: 10px;
background-color: aliceblue;
border-radius: 10px;
line-height: 40px;
font-family: 'Orbitron';
color: #4b4b4b;
padding: 0;
}
.exercise-url-text{
display: inline-block;
width: calc(100% - 40px);
padding-left: 10px;
padding-right: 10px;
text-align: center;
white-space: nowrap;
overflow-x: scroll;
}
.exercise-url-text::-webkit-scrollbar{
display: none;
background-color: transparent;
}
.exercise-open-url{
display: inline-block;
color: #4b4b4b;
width: 35px;
height: 40px;
vertical-align: top;
border-top-right-radius: 10px;
border-bottom-right-radius: 10px;
text-align: center;
}

.fa-up-right-from-square{
font-size: 20px;
width: 35px;
/* height: 40px; */
color: #696969;
}
.fa-up-right-from-square:hover{
color: #808080;
}
.exercise-thumbnail{
margin: 0!important;
display: inline-block;
height:100%;
width:calc(55% - 15px);
}
.exercise-public{
margin: 0!important;
display: inline-block;
font-family: 'Syncopate';
font-size: 20px;
vertical-align: top;
text-align: center;
height:100%;
background-color: aqua;
width:calc(44.1% - 15px);
padding-top: 5px;
}
.exercise-remove-wrapper{
margin: 0!important;
display: inline-block;
width: 22px;
height: 100%;
vertical-align: top;
text-align: end;
}
.exercise-remove{
transform: rotate(45deg);
font-size: 35px;
line-height: 26px;
font-weight: 400;

cursor: pointer;
color: #afafaf;
}
.exercise-remove:hover{
color:#f4eb49;
}
4 changes: 2 additions & 2 deletions static/css/nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,9 @@ body{
width: 30px;
text-align: center;
}
/* .sidebar-icon{
.sidebar-icon{
color: #e0e0e0;
} */
}
/* .sidebar-icon-selected{
color: #f4eb49
} */
Expand Down
68 changes: 68 additions & 0 deletions static/js/exercises.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@

// File Dropdown
// Alert accept popup
function uploadFileAlert(msg) {
var el = document.createElement("div");
el.setAttribute("class", "alertPopupAccept");
el.innerHTML = msg;
var optionWrapper = document.createElement("div");
optionWrapper.setAttribute('class', 'optionWrapper');
var cancel = document.createElement('button');
cancel.setAttribute('class', 'cancelToggle toggleButton');
cancel.innerHTML = 'Cancel';
var contin = document.createElement('button');
contin.setAttribute('class', 'continueToggle toggleButton');
contin.innerHTML = 'Continue';
optionWrapper.append(cancel);
optionWrapper.append(contin);
el.append(optionWrapper);


document.body.appendChild(el);
$(".continueToggle").on('click', function (e) {

$(".alertPopupAccept").css('animation', 'slideC 1s');
$('.toggleActiveIcon').attr('class', 'fas fa-toggle-on toggleOn toggleActiveIcon')
setTimeout(function () {
$(".alertPopupAccept").remove();
}, 1000);

$.ajax({
type: "POST",
url: "dashboard/toggleWeek/",
data: {
phase: selectedPhase,
week: selectedWeek,
csrfmiddlewaretoken: csrf_token,
dataType: "json",
},
success: function (data) {
if (data['success']) {

tempAlert(data['success'], 4000, 1);
$('.toggleOff').on('click', function () {
tempAcceptAlert('Make this the active week?');
});
} else {
tempAlert(data['error'], 4000, 0);
$('.toggleActiveIcon').attr('class', 'fas fa-toggle-off toggleOff toggleActiveIcon')
$('.toggleOff').on('click', function () {
tempAcceptAlert('Make this the active week?');
});
}

},
failure: function () {
tempAlert('Couldnt Activate Week', 4000, 0);
$('.toggleActiveIcon').attr('class', 'fas fa-toggle-off toggleOff toggleActiveIcon')
}
});

});
$(".cancelToggle").on('click', function (e) {
$(".alertPopupAccept").css('animation', 'slideC 1s');
setTimeout(function () {
$(".alertPopupAccept").remove();
}, 1000);
});
};
97 changes: 50 additions & 47 deletions trainerInterface/splitViews/exercises.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,62 +6,65 @@


def exercises(request):
request.session["href"] = '/dashboard/exercises/'
exerciseForm = AddExercise()
exercises = ExerciseType.objects.all().order_by('name')

if request.method == "POST":
processForm(request)
if request.FILES['excel_file']:
processForm(request)
print(request.FILES['excel_file'])

if 'uploadFile' in request.POST:
excel_file = request.FILES["excel_file"]
# if 'uploadFile' in request.POST:
# excel_file = request.FILES["excel_file"]

# you may put validations here to check extension or file size
wb = openpyxl.load_workbook(excel_file.temporary_file_path())
# # you may put validations here to check extension or file size
# wb = openpyxl.load_workbook(excel_file.temporary_file_path())

# getting a particular sheet by name out of many sheets
worksheet = wb["Sheet1"]
print(worksheet)
# # getting a particular sheet by name out of many sheets
# worksheet = wb["Sheet1"]
# print(worksheet)

worksheet.delete_rows(0)
for row in worksheet.iter_rows():
if not ExerciseType.objects.filter(name=row[0].value).exists():
exercise = ExerciseType(
name=row[0].value,
description=row[1].value,
video=row[2].value,
)
exercise.save()
print("exercise " + exercise.name + " saved")
else:
exercise = ExerciseType.objects.get(name=row[0].value)
exercise.description = row[1].value
exercise.video = row[2].value
exercise.save()
print("exercise " + row[0].value + " updated")
if 'addExercise' in request.POST:
# worksheet.delete_rows(0)
# for row in worksheet.iter_rows():
# if not ExerciseType.objects.filter(name=row[0].value).exists():
# exercise = ExerciseType(
# name=row[0].value,
# description=row[1].value,
# video=row[2].value,
# )
# exercise.save()
# print("exercise " + exercise.name + " saved")
# else:
# exercise = ExerciseType.objects.get(name=row[0].value)
# exercise.description = row[1].value
# exercise.video = row[2].value
# exercise.save()
# print("exercise " + row[0].value + " updated")
# if 'addExercise' in request.POST:

addedExercise = AddExercise(request.POST, request.FILES)
if addedExercise.is_valid():
name = addedExercise.cleaned_data.get("name")
description = addedExercise.cleaned_data.get("description")
image = addedExercise.cleaned_data.get("image")
video = addedExercise.cleaned_data.get("video")
if not ExerciseType.objects.filter(name=name).exists():
exercise = ExerciseType(
name=name,
description=description,
image=image,
video=video,
)
exercise.save()
print("exercise " + name + " saved")
else:
exercise = ExerciseType.objects.get(name=name)
exercise.description = description
exercise.image = image
exercise.video = video
exercise.save()
print("exercise " + name + " updated")
# addedExercise = AddExercise(request.POST, request.FILES)
# if addedExercise.is_valid():
# name = addedExercise.cleaned_data.get("name")
# description = addedExercise.cleaned_data.get("description")
# image = addedExercise.cleaned_data.get("image")
# video = addedExercise.cleaned_data.get("video")
# if not ExerciseType.objects.filter(name=name).exists():
# exercise = ExerciseType(
# name=name,
# description=description,
# image=image,
# video=video,
# )
# exercise.save()
# print("exercise " + name + " saved")
# else:
# exercise = ExerciseType.objects.get(name=name)
# exercise.description = description
# exercise.image = image
# exercise.video = video
# exercise.save()
# print("exercise " + name + " updated")

form = getUserform(request)

Expand Down
Loading

0 comments on commit 2fcc1d2

Please sign in to comment.