class ClassType(ObjectType): id = String(required=True) gym_id = String() gym = Field(GymType) location = String(required=True) details_id = String(required=True) details = Field(ClassDetailType, required=True) date = Date(required=True) start_time = Time() end_time = Time() instructor = String(required=True) is_cancelled = Boolean(required=True) image_url = String(required=True) def resolve_gym(self, info): return Data.gyms.get(self.gym_id) def resolve_details(self, info): return Data.class_details.get(self.details_id) def filter(self, detail_ids=None, day=None, name=None, tags=None, gym_id=None, instructor=None): details = Data.class_details.get(self.details_id) return ((detail_ids is None or self.details_id in detail_ids) and (day is None or day == self.date) and (name is None or name in details.name) and (tags is None or any([tag in details.tags for tag in tags])) and (gym_id is None or gym_id == self.gym_id) and (instructor is None or instructor in self.instructor))
class Input: id = IntID(required=True) worker = IntID(required=True) report_date = Date(required=True) func_role = IntID(required=True) projects = graphene.List(IntID, required=True) process = IntID() sub_process = IntID() tasks = IntID() task = graphene.String() time_spent = Time(required=True) time_from = Time() time_to = Time() place = IntID(required=True) distance = graphene.Float() car = graphene.String() gas = graphene.String() where_from = graphene.String() where_to = graphene.String() money_spent = graphene.Int() vc_project = graphene.Int() vc_digits = graphene.Int() vc_digits_minor = graphene.Int() model = graphene.String() night_shift = graphene.Boolean() quality_grade = graphene.Int() time_grade = graphene.Int() comment = graphene.String()
class Input: worker = IntID(required=True) begin = DateTime(required=True) end = DateTime(required=True) time = Time() reason = IntID(required=True) comment = String()
class Input: id = IntID(required=True, description='ID отсутствия для изменения') worker = IntID(required=True) begin = DateTime(required=True) end = DateTime(required=True) time = Time() reason = IntID(required=True) comment = String()
def generate_type_dict(model): type_dict = {} for column in model.__table__.columns: if hasattr(model, 'private_fields') and column.name in model.private_fields: continue if column.type.python_type == int: type_dict[column.name] = Int() elif column.type.python_type == str: type_dict[column.name] = String() elif column.type.python_type == datetime.datetime: type_dict[column.name] = DateTime() elif column.type.python_type == datetime.date: type_dict[column.name] = Date() elif column.type.python_type == datetime.time: type_dict[column.name] = Time() elif column.type.python_type == bool: type_dict[column.name] = Boolean() elif column.type.python_type == decimal.Decimal: type_dict[column.name] = Float() else: raise Exception(f'Unknown column type {column.type.python_type}') return type_dict
def convert_time_to_string(field, registry=None, input_flag=None, nested_fields=False): return Time(description=field.help_text or field.verbose_name, required=is_required(field) and input_flag == 'create')
def convert_time_to_string(field, registry=None): return Time(description=field.help_text, required=not field.null)
class Query(ObjectType): schedule = SQLAlchemyConnectionField( Schedule, room=Int(required=True), day=Date(required=True), description="Поиск расписания занятий и зачётов по аудитории.") filter_group = SQLAlchemyConnectionField(Schedule, group=Int(required=True), day=Date(required=True), description="Фильтр по группам.") filter_teacher = SQLAlchemyConnectionField( Schedule, teacher=Int(required=True), day=Date(required=True), description="Фильтр по учителям.") exams = SQLAlchemyConnectionField( Exams, room=Int(required=False), day=Date(required=False), range=Date(required=False), description="Поиск расписания экзаменов и консультаций по аудитории.") gosses = SQLAlchemyConnectionField( Gosses, room=Int(required=False), day=Date(required=False), range=Date(required=False), description="Поиск расписания государственных экзаменов по аудитории.") test = SQLAlchemyConnectionField( Schedule, day=Date(required=True), now=Time(required=True), facility=Int(required=True), description="Список активных занятий в определенное время.") rooms = SQLAlchemyConnectionField(Rooms, id=Int(required=False), description="Поиск аудиторий(id).") node = relay.Node.Field() study_time = relay.node.Field(StudyTime, description="") week_day = SQLAlchemyConnectionField(WeekType, description="") lesson_type = SQLAlchemyConnectionField(LessonType, description="") day_type = SQLAlchemyConnectionField(DayType, description="") person = SQLAlchemyConnectionField(Personnel, description="") kurs_type = SQLAlchemyConnectionField(KursType, description="") wplan_kurs = SQLAlchemyConnectionField(WplanKurs, description="") block_type = SQLAlchemyConnectionField(BlockType, description="") teachers = SQLAlchemyConnectionField(Teachers, description="") corpus_type = SQLAlchemyConnectionField(CorpusType, description="") group = SQLAlchemyConnectionField(GroupSh, description="") wplangos = SQLAlchemyConnectionField(Wplangosexam, description="") def resolve_test(self, info, **args): day = args.get("day") facility = args.get("facility") now = args.get("now") res = Schedule.get_query(info).\ join(StudytimeModel).\ join(RoomsModel, CorpustypeModel).\ filter(CorpustypeModel.id == facility).\ filter( between(day, ScheduleModel.sem_beg, ScheduleModel.sem_end) ).\ filter( between(now, StudytimeModel.time_start, StudytimeModel.time_end) ).\ all() return res def resolve_rooms(self, info, **args): id = args.get("id") res = Rooms.get_query(info) if id: res = Rooms.get_query(info).\ join(CorpustypeModel).\ filter(CorpustypeModel.id == id) return res.all() def resolve_schedule(self, info, **args): room = args.get("room") last_day = args.get("day") first_day = last_day - timedelta(days=6) res = Schedule.get_query(info).\ filter(ScheduleModel.id_rooms == room).\ filter( or_( between(last_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(first_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(ScheduleModel.sem_beg, first_day, last_day), between(ScheduleModel.sem_end, first_day, last_day) ) ).all() return res def resolve_filter_group(self, info, **args): last_day = args.get("day") group = args.get("group") first_day = last_day - timedelta(days=6) res = Schedule.get_query(info).\ join(GroupshModel).\ filter(GroupshModel.id == group).\ filter( or_( between(last_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(first_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(ScheduleModel.sem_beg, first_day, last_day), between(ScheduleModel.sem_end, first_day, last_day) ) ).all() return res def resolve_filter_teacher(self, info, **args): last_day = args.get("day") teacher = args.get("teacher") first_day = last_day - timedelta(days=6) res = Schedule.get_query(info).\ join(PersonnelModel).\ join(TeachersModel).\ filter(TeachersModel.id == teacher).\ filter( or_( between(last_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(first_day, ScheduleModel.sem_beg, ScheduleModel.sem_end), between(ScheduleModel.sem_beg, first_day, last_day), between(ScheduleModel.sem_end, first_day, last_day) ) ).all() return res def resolve_exams(self, info, **args): room = args.get("room") today = args.get("day") res = Exams.get_query(info).\ filter(SchedulexamModel.id_room == room). \ filter(SchedulexamModel.date_exam == today) return res.all() def resolve_gosses(self, info, **args): room = args.get("room") today = args.get("sdate") res = Gosses.get_query(info).\ filter(SchedulegosexamModel.id_room == room). \ filter(SchedulegosexamModel.date_exam == today) return res.all()
def convert_form_field_to_time(field): return Time(description=field.help_text, required=field.required)
class TimeRangeType(ObjectType): end_time = Time(required=True) restrictions = String(default_value="", required=True) special_hours = Boolean(default_value=False, required=True) start_time = Time(required=True)