Commit bfa002aa authored by Martin Juhás's avatar Martin Juhás
Browse files

feat: add an option to specify allowed file types that can be uploaded during an exercise

### Additions

* added new field `allowedFileTypes: [String!]!` to `ConfigType` type

Closes #543
parent 4c4bea6a
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -15,7 +15,7 @@ from exercise.graphql_inputs import (
    CreateExerciseInput,
)
from exercise.lib.exercise_manager import ExerciseManager
from exercise.models import Team, MilestoneState, Exercise
from exercise.models import Team, MilestoneState, Exercise, ExerciseState
from exercise_definition.lib.definition_uploader import DefinitionUploader
from exercise_definition.models import Definition, Milestone
from user.models import User
@@ -209,3 +209,10 @@ def make_accounts(

    User.objects.bulk_create(users)
    return users


def start_exercise(exercise: Exercise) -> Exercise:
    state = exercise.single_state()
    state.status = ExerciseState.Status.RUNNING
    state.save()
    return exercise
+11 −0
Original line number Diff line number Diff line
## 0.24.5
Issues: inject/backend#543, inject/inject-issues#167

Added an option to specify a whitelist of file types that can be uploaded during an exercise.

### config.yml

- added field `allowed_file_types`


## 0.24.4
Issues: inject/backend#536, inject/inject-issues#308

@@ -8,6 +18,7 @@ Allow empty answers for free-form questions.
- changed default value of `min` field to `0` on `free-form` questions,
  `auto-free-form` questions still have `1` as default and do not accept `0`


## 0.24.3
Issues: inject/backend#525

+20 −0
Original line number Diff line number Diff line
@@ -169,6 +169,26 @@ All advanced features are disabled by default:
- **authors**: _list of strings, default=empty_ - List of authors.
- **instructor_notes**: _[content](#content), default=empty_ - information only available to instructors
- **notes**: _[content](#content), default=empty_ - General notes about the definition.
- **allowed_file_types**: _list of strings, default=predefined list of allowed file types_ -
  a **whitelist**  of allowed file types specified with their [mimetype](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types).
  By default, the list contains these file types:
    - text/plain
    - text/markdown
    - application/vnd.ms-excel
    - application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
    - application/msword
    - application/vnd.openxmlformats-officedocument.wordprocessingml.document
    - image/png
    - image/jpeg
    - application/pdf

  _Note_: This list you specify will be **the final** list.
  The above defaults **will not be added** to it.
  If you wish to allow more file types, you must include the default file types as well.
  Additionally, you may choose to disallow file uploads entirely
  during the exercise by specifying an empty list (`[]`).
  These restrictions apply to _all_ users for the specific exercise,
  including instructors and admins.
- **version**: _string_ - semver version string of the format this definition uses, see [versioning](#versioning) for details.

### objectives.yml
+6 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ exercise_duration: 60
show_exercise_time: False
show_exercise_overview: True
instructor_required: True
version: 0.24.4
version: 0.24.5
description: Some description about this definition.
instructor_notes: { content: Some notes about this definition }
target_audience: Some description of target audience
@@ -25,3 +25,8 @@ authors:
license: license 
language: en 
notes: { content: General notes about this definition }
allowed_file_types:
  - text/plain
  - text/markdown
  - image/png
  - image/jpeg
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ exercise_duration: 60
email_between_teams: True
show_exercise_time: False
instructor_required: False
version: 0.24.4
version: 0.24.5
description: |
  Long description about this definition.Long description about this definition.Long description about this definition.
  Long description about this definition.Long description about this definition.Long description about this definition.
Loading