Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
tdt4242-SecFit
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Nikolai Roede Dokken
tdt4242-SecFit
Commits
1ececa6b
Commit
1ececa6b
authored
2 years ago
by
NikolaiDokken
Browse files
Options
Downloads
Patches
Plain Diff
post group done
parent
9148240a
No related branches found
No related tags found
1 merge request
!2
Feat/add group
Pipeline
#161435
passed with stage
in 21 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
backend/secfit/groups/serializers.py
+2
-17
2 additions, 17 deletions
backend/secfit/groups/serializers.py
frontend/www/myathletes.html
+1
-1
1 addition, 1 deletion
frontend/www/myathletes.html
frontend/www/scripts/group.js
+20
-11
20 additions, 11 deletions
frontend/www/scripts/group.js
with
23 additions
and
29 deletions
backend/secfit/groups/serializers.py
+
2
−
17
View file @
1ececa6b
from
rest_framework
import
serializers
from
groups.models
import
Group
from
django.contrib.auth
import
get_user_model
import
logging
class
GroupSerializer
(
serializers
.
HyperlinkedModelSerializer
):
class
Meta
:
...
...
@@ -13,27 +12,13 @@ class GroupSerializer(serializers.HyperlinkedModelSerializer):
]
def
create
(
self
,
validated_data
):
logger
=
logging
.
getLogger
(
'
django
'
)
name
=
validated_data
[
"
name
"
]
coach
=
validated_data
[
"
coach
"
]
#athletes = validated_data["athletes"]
#coach = get_user_model().objects.filter
#athletes = athletes.split(",")
#logging.info("Log message goes here.")
#logging.info(athletes)
files_data
=
[]
if
"
athletes
"
in
validated_data
:
files_data
=
validated_data
.
pop
(
"
athletes
"
)
group_obj
=
Group
.
objects
.
create
(
**
validated_data
)
for
ath
in
files_data
:
logging
.
info
(
"
SBDHJSBDHJASBDADJHADBS NEGER
"
)
group_obj
.
athletes
.
push
(
ath
)
# group_obj.save()
#print(athletes)
#for athlete in athletes:
# group_obj.athletes.set(athlete)
group_obj
.
athletes
.
set
(
files_data
)
return
group_obj
...
...
This diff is collapsed.
Click to expand it.
frontend/www/myathletes.html
+
1
−
1
View file @
1ececa6b
...
...
@@ -50,7 +50,7 @@
<div
id=
"list-groups-div"
class=
"col-lg-6"
>
<label
for=
"group-control"
class=
"form-label mt-2"
>
Groups
</label>
<div
id=
"group-control"
></div>
<input
class=
"form-control"
name=
"group"
type=
"text"
placeholder=
"
Comma-separated
username
s
"
id=
"group-input"
/>
<input
class=
"form-control"
name=
"group"
type=
"text"
placeholder=
"
Group name: username1,
username
2
"
id=
"group-input"
/>
<input
type=
"button"
class=
"btn btn-primary mt-1 mb-2"
id=
"button-submit-group"
value=
"Submit"
>
</div>
</div>
...
...
This diff is collapsed.
Click to expand it.
frontend/www/scripts/group.js
+
20
−
11
View file @
1ececa6b
function
generateGroupForm
()
{
async
function
generateGroupForm
()
{
let
form
=
document
.
querySelector
(
"
#form-group
"
);
let
formData
=
new
FormData
(
form
);
...
...
@@ -6,19 +6,27 @@ function generateGroupForm() {
let
input
=
formData
.
get
(
"
group
"
);
let
groupName
=
input
.
split
(
"
:
"
)[
0
];
let
athletes
=
input
.
split
(
"
:
"
)[
1
].
split
(
"
,
"
)[
0
];
submitForm
.
append
(
"
name
"
,
"
Nikos gruppe 3
"
);
submitForm
.
append
(
"
athletes
"
,
[
"
http://localhost:8000/api/users/7/
"
,
"
http://localhost:8000/api/users/8/
"
,
]);
submitForm
.
append
(
"
coach
"
,
"
http://localhost:8000/api/users/6/
"
);
submitForm
.
append
(
"
name
"
,
groupName
);
let
athletes
=
input
.
split
(
"
:
"
)[
1
].
replaceAll
(
"
"
,
""
).
split
(
"
,
"
);
let
currentUser
=
await
getCurrentUser
();
for
(
let
athlete
of
athletes
)
{
let
response
=
await
sendRequest
(
"
GET
"
,
`
${
HOST
}
/api/users/
${
athlete
}
/`
);
let
result
=
await
response
.
json
();
submitForm
.
append
(
"
athletes
"
,
result
.
url
);
}
console
.
log
(
currentUser
.
url
);
submitForm
.
append
(
"
coach
"
,
currentUser
.
url
);
return
submitForm
;
}
async
function
createGroup
()
{
let
submitForm
=
generateGroupForm
();
let
submitForm
=
await
generateGroupForm
();
let
response
=
await
sendRequest
(
"
POST
"
,
...
...
@@ -28,7 +36,8 @@ async function createGroup() {
);
if
(
response
.
ok
)
{
// window.location.reload();
document
.
getElementById
(
"
group-input
"
).
value
=
""
;
window
.
location
.
reload
();
return
;
}
else
{
let
data
=
await
response
.
json
();
...
...
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