Ejemplo n.º 1
0
from controllers.course.deliverables_results import deliverable_results_controller
from controllers.relations.learns import student_course_relation_controller
from controllers.course.courses import courses_controller
from controllers.relations.student_group_relation import StudentGroupRelationController
from controllers.relations.group_course_relation import group_course_controller
from methods.auth import *
from flask_restful import Resource, reqparse
from flask import current_app, jsonify

controller_object = student_course_relation_controller()
delivers_object = deliverable_results_controller()
group_obj = StudentGroupRelationController()
course_obj = courses_controller()
gc_obj = group_course_controller()

# /student/<student_id>/courses


class Student_Course_Relation(Resource):
    method_decorators = {'post': [requires_auth_identity("")]}

    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        self.reqparse.add_argument('course_code', type=str, location='json')

    def get(self, student_id):
        try:
            student_courses = controller_object.get_courses_by_student_id(
                student_id)
        except ErrorHandler as e:
            return e.error
from models.user.users import User
from controllers.relations.delivers import delivers_controller
from controllers.course.group_project import GroupProjectController
from controllers.course.events import events_controller
from controllers.relations.group_course_relation import group_course_controller
from controllers.relations.student_group_relation import StudentGroupRelationController
from flask import json
from datetime import datetime
from sqlalchemy import func
import math

delivers_controller_object = delivers_controller()
groups_controller = GroupProjectController()
events_controllers = events_controller()
group_course_controller_object = group_course_controller()
student_object = StudentGroupRelationController()


class deliverable_controller:
    def get_deliverable(self, deliverable_id):
        deliverable = Deliverables.query.filter_by(
            deliverable_id=deliverable_id).first()
        if not deliverable:
            raise ErrorHandler({
                'description': 'deliverable does not exist.',
                'status_code': 404
            })
        deliverable.deadline = json.dumps(deliverable.deadline,
                                          default=str).replace("\"", "")
        return deliverable.serialize()
Ejemplo n.º 3
0
from controllers.course.deliverables import deliverable_controller
from controllers.relations.student_group_relation import StudentGroupRelationController
from flask_restful import Resource, reqparse
import werkzeug
from flask import jsonify
from methods.errors import *
from methods.auth import *

controller_object = deliverable_controller()
group_controller = StudentGroupRelationController()


# /deliverables/<deliverable_id>
class Deliverable_view(Resource):
    def __init__(self):
        self.reqparse = reqparse.RequestParser()
        self.reqparse.add_argument('deliverable_name',
                                   type=str,
                                   location='json')
        self.reqparse.add_argument('deadline', type=str,
                                   location='json')  #date time not str
        self.reqparse.add_argument('course_deliverables',
                                   type=str,
                                   location='json')
        self.reqparse.add_argument('students_number',
                                   type=int,
                                   location='json')
        self.reqparse.add_argument('students_number',
                                   type=int,
                                   location='json')
        self.reqparse.add_argument('description', type=str, location='json')