Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
DRIESASTER committed May 18, 2024
1 parent a4c5d23 commit cac4038
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 36 deletions.
3 changes: 2 additions & 1 deletion backend/src/project/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ async def put_test_files(

if not using_default_docker_image(uuid):
# build custom docker image if dockerfile is present
background_tasks.add_task(build_docker_image, tests_path(uuid), uuid, client)
background_tasks.add_task(
build_docker_image, tests_path(uuid), uuid, client)

return await update_test_files(db, project.id, uuid)

Expand Down
1 change: 0 additions & 1 deletion backend/src/project/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ class ProjectUpdate(BaseModel):
description: Optional[str] = None
requirements: Optional[List[Requirement]] = None
is_visible: Optional[bool] = None
id: int

@field_validator("deadline")
def validate_deadline(cls, value: datetime) -> datetime:
Expand Down
3 changes: 2 additions & 1 deletion backend/src/project/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ async def create_project(db: AsyncSession, project_in: ProjectCreate) -> Project
description=project_in.description,
is_visible=project_in.is_visible,
capacity=project_in.capacity,
requirements=[Requirement(**r.model_dump()) for r in project_in.requirements],
requirements=[Requirement(**r.model_dump())
for r in project_in.requirements],
)
db.add(new_project)
await db.commit()
Expand Down
25 changes: 0 additions & 25 deletions backend/tests/test_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,28 +112,3 @@ async def test_patch_project(client: AsyncClient, db: AsyncSession, project_id:
assert response.status_code == 200
response = await client.get(f"/api/projects/{project_id}")
assert response.json()["description"] == "new description"


@pytest.mark.asyncio
async def test_is_visible_project(client: AsyncClient, db: AsyncSession, project_id: int):

response = await client.get(f"/api/projects/{project_id}")
subject_id = response.json()["subject_id"]

await set_admin(db, "test", True)
await client.patch(f"/api/projects/{project_id}", json={"is_visible": False})
await set_admin(db, "test", False)

response = await client.get(f"/api/projects/{project_id}")
assert response.status_code == 404 # Not found as project is not visible

response = await client.get(f"/api/subjects/{subject_id}/projects")
assert len(response.json()["projects"]) == 0

# Now privileged get request
await make_instructor(subject_id, "test", db, client)
response = await client.get(f"/api/projects/{project_id}")
assert response.status_code == 200

response = await client.get(f"/api/subjects/{subject_id}/projects")
assert len(response.json()["projects"]) == 1
1 change: 0 additions & 1 deletion frontend/src/components/project/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ function formatTime(date: Date): string {
watch(
[date, time],
() => {
console.log("updated time", time);
const [hours, minutes] = time.value.split(":").map(Number);
const updatedDate = new Date(date.value);
updatedDate.setHours(hours, minutes, 0, 0);
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/views/CreateProjectView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -144,14 +144,13 @@ const requirements = ref([]);
const projectId = ref(route.params.projectId);
const isEditMode = computed(() => projectId.value !== undefined);
console.log("isEditMode:", isEditMode);
const {
data: projectData,
isLoading: isProjectLoading,
isError: isProjectError,
} = useProjectQuery(projectId);
console.log(projectId);
const {
data: filesData,
isLoading: isFilesLoading,
Expand All @@ -167,14 +166,12 @@ watch(
projectData,
(project) => {
if (project) {
console.log("project", project);
project_title.value = project.name;
deadline.value = new Date(project.deadline);
publishDate.value = new Date(project.publish_date);
requirements.value = project.requirements.map((req) => ({ ...req }));
const description = project.description;
selectedSubject.value = project.subject_id;
console.log(selectedSubject);
nextTick(() => {
if (quillEditor.value && quillEditor.value.getQuill) {
let quill = quillEditor.value.getQuill();
Expand Down Expand Up @@ -269,7 +266,6 @@ function setErrorAlert(message) {
async function submitForm() {
const projectData = formatProjectData();
console.log(projectData);
try {
if (isEditMode.value) {
await updateProject(projectData);
Expand Down Expand Up @@ -315,13 +311,11 @@ async function createProject(projectData) {
}
async function handleGroupCreation(projectId) {
console.log(selectedGroupProject.value);
if (selectedGroupProject.value === "student" && capacity.value != 1) {
const emptyGroups = generateEmptyGroups(projectId);
await createGroupsMutation.mutateAsync({ projectId, groups: emptyGroups });
} else if (selectedGroupProject.value === "random" || capacity.value === 1) {
const groups = divideStudentsIntoGroups(studentsData.value || [], capacity.value);
console.log(groups);
const groupsToCreate = groups.map((_, i) => ({
project_id: projectId,
score: 0,
Expand Down

0 comments on commit cac4038

Please sign in to comment.