Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TDT4242-group15
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Vegard Murvold Sporstøl
TDT4242-group15
Commits
5fb6df7e
Commit
5fb6df7e
authored
4 years ago
by
Vegard Murvold Sporstøl
Browse files
Options
Downloads
Patches
Plain Diff
set athlete as owner working
parent
355e9d97
Branches
UC-2
Branches containing commit
No related tags found
1 merge request
!6
Uc 1
Pipeline
#113788
passed
4 years ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/secfit/workouts/serializers.py
+3
-0
3 additions, 0 deletions
backend/secfit/workouts/serializers.py
backend/secfit/workouts/views.py
+5
-1
5 additions, 1 deletion
backend/secfit/workouts/views.py
frontend/www/scripts/workout.js
+5
-4
5 additions, 4 deletions
frontend/www/scripts/workout.js
with
13 additions
and
5 deletions
backend/secfit/workouts/serializers.py
+
3
−
0
View file @
5fb6df7e
...
...
@@ -98,7 +98,9 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
if
"
files
"
in
validated_data
:
files_data
=
validated_data
.
pop
(
"
files
"
)
print
(
validated_data
)
workout
=
Workout
.
objects
.
create
(
**
validated_data
)
print
(
workout
)
for
exercise_instance_data
in
exercise_instances_data
:
ExerciseInstance
.
objects
.
create
(
workout
=
workout
,
**
exercise_instance_data
)
...
...
@@ -127,6 +129,7 @@ class WorkoutSerializer(serializers.HyperlinkedModelSerializer):
instance
.
name
=
validated_data
.
get
(
"
name
"
,
instance
.
name
)
instance
.
notes
=
validated_data
.
get
(
"
notes
"
,
instance
.
notes
)
instance
.
owner
=
validated_data
.
get
(
"
owner
"
,
instance
.
owner
)
instance
.
visibility
=
validated_data
.
get
(
"
visibility
"
,
instance
.
visibility
)
instance
.
date
=
validated_data
.
get
(
"
date
"
,
instance
.
date
)
instance
.
save
()
...
...
This diff is collapsed.
Click to expand it.
backend/secfit/workouts/views.py
+
5
−
1
View file @
5fb6df7e
...
...
@@ -26,6 +26,7 @@ from workouts.models import Workout, Exercise, ExerciseInstance, WorkoutFile
from
workouts.serializers
import
WorkoutSerializer
,
ExerciseSerializer
from
workouts.serializers
import
RememberMeSerializer
from
workouts.serializers
import
ExerciseInstanceSerializer
,
WorkoutFileSerializer
from
django.contrib.auth
import
get_user_model
from
django.core.exceptions
import
PermissionDenied
from
rest_framework_simplejwt.tokens
import
RefreshToken
from
rest_framework.response
import
Response
...
...
@@ -128,7 +129,10 @@ class WorkoutList(
return
self
.
create
(
request
,
*
args
,
**
kwargs
)
def
perform_create
(
self
,
serializer
):
serializer
.
save
(
owner
=
self
.
request
.
user
)
owner
=
self
.
request
.
POST
.
get
(
"
owner
"
)
User
=
get_user_model
()
user
=
User
.
objects
.
get
(
username
=
owner
)
serializer
.
save
(
owner
=
user
)
def
get_queryset
(
self
):
qs
=
Workout
.
objects
.
none
()
...
...
This diff is collapsed.
Click to expand it.
frontend/www/scripts/workout.js
+
5
−
4
View file @
5fb6df7e
...
...
@@ -122,6 +122,7 @@ async function retrieveWorkout(id) {
function
handleCancelDuringWorkoutEdit
()
{
location
.
reload
();
}
function
athleteChecked
()
{
let
checkBox
=
document
.
getElementById
(
"
forAthlete
"
);
let
athletes
=
document
.
getElementById
(
"
athletes
"
);
...
...
@@ -134,17 +135,14 @@ function athleteChecked() {
myself
.
style
.
display
=
"
block
"
;
}
}
async
function
athletesInDropdown
()
{
let
ath
=
document
.
getElementById
(
"
athletes
"
);
let
currentUser
=
await
getCurrentUser
();
console
.
log
(
"
hei
"
);
console
.
log
(
currentUser
.
username
);
console
.
log
(
currentUser
.
athletes
);
for
(
let
athleteUrl
of
currentUser
.
athletes
)
{
let
newElement
=
document
.
createElement
(
"
option
"
);
let
response
=
await
sendRequest
(
"
GET
"
,
athleteUrl
);
let
athlete
=
await
response
.
json
();
console
.
log
(
athlete
);
newElement
.
text
=
athlete
.
username
;
ath
.
add
(
newElement
);
}
...
...
@@ -157,6 +155,7 @@ function handleEditWorkoutButtonClick() {
setReadOnly
(
false
,
"
#form-workout
"
);
document
.
querySelector
(
"
#inputOwner
"
).
readOnly
=
true
;
// owner field should still be readonly
document
.
querySelector
(
"
#forAthlete
"
).
hidden
=
true
editWorkoutButton
.
className
+=
"
hide
"
;
okWorkoutButton
.
className
=
okWorkoutButton
.
className
.
replace
(
"
hide
"
,
""
);
...
...
@@ -221,6 +220,7 @@ function generateWorkoutForm() {
submitForm
.
append
(
"
name
"
,
formData
.
get
(
"
name
"
));
let
date
=
new
Date
(
formData
.
get
(
"
date
"
)).
toISOString
();
submitForm
.
append
(
"
date
"
,
date
);
submitForm
.
append
(
"
owner
"
,
formData
.
get
(
"
owner_username
"
))
submitForm
.
append
(
"
notes
"
,
formData
.
get
(
"
notes
"
));
submitForm
.
append
(
"
visibility
"
,
formData
.
get
(
"
visibility
"
));
...
...
@@ -247,6 +247,7 @@ function generateWorkoutForm() {
async
function
createWorkout
()
{
let
submitForm
=
generateWorkoutForm
();
console
.
log
(
submitForm
)
let
response
=
await
sendRequest
(
"
POST
"
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment