Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
IDATT2900-072
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Mattias Agentoft Eggen
IDATT2900-072
Commits
cb2a3756
Commit
cb2a3756
authored
3 years ago
by
magnus2142
Browse files
Options
Downloads
Patches
Plain Diff
added delete contents method
parent
90082a60
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bbcli/cli.py
+2
-1
2 additions, 1 deletion
bbcli/cli.py
bbcli/commands/contents.py
+17
-0
17 additions, 0 deletions
bbcli/commands/contents.py
bbcli/services/contents_service.py
+10
-0
10 additions, 0 deletions
bbcli/services/contents_service.py
with
29 additions
and
1 deletion
bbcli/cli.py
+
2
−
1
View file @
cb2a3756
...
...
@@ -9,7 +9,7 @@ import click
from
bbcli.commands.courses
import
list_courses
from
bbcli.commands.announcements
import
list_announcements
,
create_announcement
,
delete_announcement
,
update_announcement
from
bbcli.commands.contents
import
create_assignment
,
create_courselink
,
create_folder
,
list_contents
,
create_document
,
create_file
,
create_web_link
,
upload_attachment
from
bbcli.commands.contents
import
create_assignment
,
create_courselink
,
create_folder
,
delete_content
,
list_contents
,
create_document
,
create_file
,
create_web_link
,
upload_attachment
from
bbcli.services.authorization_service
import
login
load_dotenv
()
...
...
@@ -90,6 +90,7 @@ def contents(ctx):
pass
contents
.
add_command
(
list_contents
)
contents
.
add_command
(
delete_content
)
"""
CONTENTS CREATE COMMANDS ENTRY POINT
...
...
This diff is collapsed.
Click to expand it.
bbcli/commands/contents.py
+
17
−
0
View file @
cb2a3756
...
...
@@ -182,6 +182,23 @@ def create_assignment(ctx, course_id: str, parent_id: str, title: str,
response
=
contents_service
.
create_assignment
(
ctx
.
obj
[
'
SESSION
'
],
course_id
,
parent_id
,
title
,
standard_options
,
grading_options
,
attachments
)
click
.
echo
(
response
)
@click.command
(
name
=
'
delete
'
)
@click.argument
(
'
course_id
'
,
required
=
True
,
type
=
str
)
@click.argument
(
'
content_id
'
,
required
=
True
,
type
=
str
)
@click.option
(
'
--delete-grades
'
,
is_flag
=
True
,
help
=
'
Deletes grades if a grade column is assosciated with the content.
'
)
@click.pass_context
def
delete_content
(
ctx
,
course_id
:
str
,
content_id
:
str
,
delete_grades
:
bool
):
"""
Deletes a content
"""
response
=
contents_service
.
delete_content
(
ctx
.
obj
[
'
SESSION
'
],
course_id
,
content_id
,
delete_grades
)
click
.
echo
(
response
)
"""
HELPER FUNCTIONS
"""
def
set_dates
(
standard_options
:
StandardOptions
,
start_date
:
str
,
end_date
:
str
):
if
start_date
:
...
...
This diff is collapsed.
Click to expand it.
bbcli/services/contents_service.py
+
10
−
0
View file @
cb2a3756
...
...
@@ -172,6 +172,16 @@ def create_assignment(session: requests.Session, course_id: str, parent_id: str,
return
response
.
text
def
delete_content
(
session
:
requests
.
Session
,
course_id
:
str
,
content_id
:
str
,
delete_grades
:
bool
):
parameters
=
{
'
deleteGrades
'
:
delete_grades
}
url
=
url_builder
.
base_v1
().
add_courses
().
add_id
(
course_id
).
add_contents
().
add_id
(
content_id
).
create
()
response
=
session
.
delete
(
url
,
params
=
parameters
)
return
response
.
text
"""
HELPER FUNCTIONS
...
...
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