Verified Commit 9f7d2473 authored by Peter Stanko's avatar Peter Stanko
Browse files

Checked extraction of the faculty id

parent f457bd64
Pipeline #31645 failed with stage
in 1 minute and 18 seconds
......@@ -86,3 +86,5 @@ def handle_portal_api_error(ex: PortalAPIError):
@rest_api.errorhandler(Exception)
def handle_default_exception(ex: Exception):
log.critical(f"[ERROR] Fatal error: {ex}")
return send_response({'message': ex}), 500
......@@ -162,11 +162,26 @@ class ProjectTestFilesRefresh(CustomResource):
@projects_namespace.param('pid', 'Project id')
@projects_namespace.response(404, 'Course not found')
@projects_namespace.response(404, 'Project not found')
class ProjectTestFilesRefresh(CustomResource):
class ProjectWriteISMUNINotes(CustomResource):
@jwt_required
@access_log
@projects_namespace.response(204, 'Project test_files updated')
@projects_namespace.response(200, 'Project is muni notepad read')
def get(self, cid: str, pid: str):
course = self.find.course(cid)
project = self.find.project(course, pid)
user_id = self.get_query_param('user_id', required=True)
user = self.find.user(user_id)
# authorization
self.permissions(course=course).require.read_submission()
log.debug(f"[REST] Get is muni notes for "
f"{project.log_name} by {self.client.log_name}")
result = self.facades.submissions.is_read_notepad(project=project, user=user)
return result
@jwt_required
@access_log
@projects_namespace.response(200, 'Project test_files updated')
def post(self, cid: str, pid: str):
course = self.find.course(cid)
project = self.find.project(course, pid)
user_id = self.get_query_param('user_id', required=True)
......
......@@ -318,7 +318,7 @@ class SubmissionISNotes(CustomResource):
# @submissions_namespace.response(200, 'Submissions review', model=review_schema)
def get(self, sid: str):
submission = self.find.submission(sid)
self.permissions(submission=submission).require.evaluate_submissions()
self.permissions(submission=submission).require.read_submission()
log.debug(f"[REST] Get IS MUNI Notepad for project {submission.project.name}"
f" by {self.client.log_name}: {submission.log_name}")
return self.facades.submissions.is_read_notepad(submission=submission)
......
......@@ -5,6 +5,8 @@ import is_api
import is_api.entities
from flask import Flask
from portal.service import errors
if TYPE_CHECKING:
from portal.database import Course, Project, User
......@@ -16,9 +18,14 @@ class IsApiWrapper:
project: 'Project' = None):
self._course = course or project.course
self._project = project
faculty_id = course.faculty_id or int(faculty_id)
fac_id = course.faculty_id
try:
if fac_id is None and faculty_id is not None:
fac_id = int(faculty_id)
except Exception as ex:
raise errors.PortalServiceError(f"Unable to extract faculty_id: {ex}")
self._api = is_api.IsApiClient(domain=domain,
faculty_id=faculty_id,
faculty_id=fac_id,
token=course.notes_access_token,
course_code=course.codename)
self._course_info = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment