Verified Commit 93359527 authored by Peter Stanko's avatar Peter Stanko
Browse files

Add also uco and email to schema

parent 5b59904c
Pipeline #31675 failed with stage
in 7 minutes and 11 seconds
......@@ -163,7 +163,7 @@ class User(Client, EntityBase):
"""
UPDATABLE = ['name', 'email', 'uco', 'gitlab_username', 'managed']
BASE_PARAMS = ['username', 'codename', 'is_admin', *UPDATABLE, 'managed', 'id']
LISTABLE = ['username', 'gitlab_username', 'name']
LISTABLE = ['username', 'gitlab_username', 'name', 'uco', 'email']
__tablename__ = 'user'
id = db.Column(db.String(length=36), db.ForeignKey('client.id'),
default=lambda: str(uuid.uuid4()), primary_key=True)
......@@ -960,7 +960,7 @@ class ReviewItem(db.Model, EntityBase):
__tablename__ = 'reviewItem'
UPDATABLE = ['content', 'file', 'line_start', 'line_end', 'line']
BASE_PARAMS = ['id', *UPDATABLE]
LISTABLE = [*BASE_PARAMS]
LISTABLE = BASE_PARAMS
id = db.Column(db.String(length=36), default=lambda: str(uuid.uuid4()), primary_key=True)
review_id = db.Column(db.String(36), db.ForeignKey('review.id', ondelete='cascade'),
nullable=False)
......
import logging
from typing import List
from portal.database import Submission, Review, User, ReviewItem
from portal.database import Review, ReviewItem, Submission, User
from portal.facade.general_facade import GeneralCRUDFacade
from portal.service.reviews import ReviewService
......@@ -15,14 +15,16 @@ class ReviewsFacade(GeneralCRUDFacade):
def create(self, submission: Submission, **data) -> Review:
if not submission.review:
self._service(submission=submission).create()
log.info(f"[REVIEW] Create review by {self.client.log_name} "
f"for {submission.log_name}: {data}")
params = dict(items=data['review_items'], author=self.client)
result = self._service(submission=submission).create_review_items(**params)
return result
def create_review_item(self, submission: Submission, author: User, items: List[dict]) \
-> Review:
return self._service(submission=submission)\
log.info(f"[REVIEW] Create review by {author} for {submission.log_name}: {items}")
return self._service(submission=submission) \
.create_review_items(author=author, items=items)
def update_item(self, item: ReviewItem, **data):
......@@ -30,4 +32,3 @@ class ReviewsFacade(GeneralCRUDFacade):
def delete_item(self, item: ReviewItem):
return self._service(item.review).delete(item)
......@@ -131,9 +131,7 @@ class SubmissionsFacade(GeneralCRUDFacade):
project = project or submission.project
user = user or submission.user
note = self._services.is_api(submission.course).read_note(
project=project,
user=user)
note = self._services.is_api(submission.course).read_note(project=project, user=user)
return note
def is_write_notepad(self, submission: Submission, data: dict = None):
......
......@@ -319,7 +319,7 @@ class ReviewItemSchema(BaseSchema, Schema):
line = fields.Int(allow_none=True)
line_start = fields.Int(allow_none=True)
line_end = fields.Int(allow_none=True)
review = NESTED('Review', only=('id', 'submission.id'))
review = NESTED('Review', onlyi=('id', 'submission.id'))
user = NESTED['user']
......
......@@ -20,7 +20,7 @@ class ReviewService(GeneralService):
allowed = []
return self.update_entity(entity, data, allowed=allowed)
def _set_item_data(self, entity: ReviewItem, **data):
def _set_item_data(self, entity: ReviewItem, data):
allowed = ReviewItem.updatable_params()
return self.update_entity(entity=entity, data=data, allowed=allowed)
......@@ -47,13 +47,9 @@ class ReviewService(GeneralService):
Returns(Review): review instance with review items
"""
for item in items:
line_start = item.get('line_start')
line_end = item.get('line_end')
line = item.get('line')
file = item.get('file')
ReviewItem(user=author, review=self.review, file=file,
line_start=line_start, line_end=line_end, line=line,
content=item['content'])
rw_item = ReviewItem(user=author, review=self.review)
self._set_item_data(rw_item, item)
log.info(f"Added review items {items} to review {self.review.id} "
f"for submission {self.submission.log_name}")
self.write_entity(self.review)
......@@ -86,5 +82,5 @@ class ReviewService(GeneralService):
"""
log.info(f"[UPDATE] Review item for submission {self.submission.log_name}: {data}")
self._set_item_data(item, **data)
self._set_item_data(item, data=data)
return item.review
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