diff --git a/app/lib/groups/src/pages/course/group_page.dart b/app/lib/groups/src/pages/course/group_page.dart index 29be38e64..d47e6a2d8 100644 --- a/app/lib/groups/src/pages/course/group_page.dart +++ b/app/lib/groups/src/pages/course/group_page.dart @@ -106,7 +106,6 @@ class GroupPageState extends State { builder: (context, snapshot) { final data = snapshot.hasData ? snapshot.data : null; final isEmpty = (data?.courses == null || data.courses.isEmpty) && - data?.school == null && (data?.schoolClass == null || data.schoolClass.isEmpty); if (isEmpty) return _EmptyGroupList(); diff --git a/app/lib/onboarding/group_onboarding/pages/share_sharecode.dart b/app/lib/onboarding/group_onboarding/pages/share_sharecode.dart index 46d224050..0e4270403 100644 --- a/app/lib/onboarding/group_onboarding/pages/share_sharecode.dart +++ b/app/lib/onboarding/group_onboarding/pages/share_sharecode.dart @@ -191,8 +191,6 @@ class _SharecodeBox extends StatelessWidget { return 'des Kurses'; case GroupType.schoolclass: return 'der Schulklasse'; - case GroupType.school: - return 'der Schule'; default: return ''; } diff --git a/app/lib/util/api.dart b/app/lib/util/api.dart index 9f1360593..91a03ff3e 100644 --- a/app/lib/util/api.dart +++ b/app/lib/util/api.dart @@ -15,7 +15,6 @@ import 'package:sharezone/util/api/connections_gateway.dart'; import 'package:sharezone/util/api/course_gateway.dart'; import 'package:sharezone/util/api/homework_api.dart'; import 'package:sharezone/util/api/school_class_gateway.dart'; -import 'package:sharezone/util/api/school_gateway.dart'; import 'package:sharezone/util/api/timetable_gateway.dart'; import 'package:sharezone/util/api/user_api.dart'; import 'package:sharezone_common/references.dart'; @@ -35,7 +34,6 @@ class SharezoneGateway { final ConnectionsGateway connectionsGateway; final CourseGateway course; final SchoolClassGateway schoolClassGateway; - final SchoolGateway schoolGateway; final TimetableGateway timetable; factory SharezoneGateway({ @@ -51,7 +49,6 @@ class SharezoneGateway { course: CourseGateway(references, memberID, connectionsGateway), schoolClassGateway: SchoolClassGateway(references, memberID, connectionsGateway), - schoolGateway: SchoolGateway(references, memberID, connectionsGateway), authUser: authUser, timetable: TimetableGateway(references, memberID), user: UserGateway(references, authUser), @@ -65,7 +62,6 @@ class SharezoneGateway { @required this.references, @required this.course, @required this.schoolClassGateway, - @required this.schoolGateway, @required this.timetable, @required this.user, }) : _authUser = authUser, diff --git a/app/lib/util/api/connections_gateway.dart b/app/lib/util/api/connections_gateway.dart index 232be686b..b1ed4089b 100644 --- a/app/lib/util/api/connections_gateway.dart +++ b/app/lib/util/api/connections_gateway.dart @@ -120,8 +120,6 @@ class ConnectionsGateway implements MyConnectionsAccesor { return 'Courses'; case GroupType.schoolclass: return 'SchoolClasses'; - case GroupType.school: - return 'School'; } throw UnimplementedError('There is no string for $groupType'); } diff --git a/app/lib/util/api/school_gateway.dart b/app/lib/util/api/school_gateway.dart deleted file mode 100644 index 74a044b7f..000000000 --- a/app/lib/util/api/school_gateway.dart +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:app_functions/app_functions.dart'; -import 'package:group_domain_models/group_domain_models.dart'; -import 'package:sharezone/util/api/connections_gateway.dart'; -import 'package:sharezone_common/references.dart'; - -class SchoolGateway { - final References references; - final String memberID; - final ConnectionsGateway _connectionsGateway; - - const SchoolGateway(this.references, this.memberID, this._connectionsGateway); - - Future> createSchool(SchoolData school) { - return references.functions.groupCreate( - memberID: memberID, - id: school.id, - data: school.toCreateJson(), - type: groupTypeToString(GroupType.school), - ); - } - - Future> leave(String schoolID) { - return _connectionsGateway.leave( - id: schoolID, - type: GroupType.school, - ); - } - - Future> edit(SchoolData schoolData) { - return references.functions.groupEdit( - id: schoolData.id, - data: schoolData.toEditJson(), - type: groupTypeToString(GroupType.school), - ); - } - - Future> editSettings( - String schoolID, CourseSettings schoolSettings) { - return references.functions.groupEditSettings( - id: schoolID, - settings: schoolSettings.toJson(), - type: groupTypeToString(GroupType.school), - ); - } - - Future> kickMember( - String schoolID, String kickedMemberID) async { - return references.functions.leave( - id: schoolID, - type: groupTypeToString(GroupType.school), - memberID: kickedMemberID, - ); - } - - Stream stream() { - return ConnectionsGateway(references, memberID) - .streamConnectionsData() - .map((connections) => connections.school); - } - - Stream> streamMembersData(String schoolID) { - return references.schools - .doc(schoolID) - .collection(CollectionNames.members) - .snapshots() - .map((snapshot) => snapshot.docs - .map((docSnap) => - MemberData.fromData(docSnap.data(), id: docSnap.id)) - .toList()); - } - - School current() => _connectionsGateway.current().school; -} diff --git a/lib/group_domain_models/lib/group_domain_models.dart b/lib/group_domain_models/lib/group_domain_models.dart index 28561416b..619da98fe 100644 --- a/lib/group_domain_models/lib/group_domain_models.dart +++ b/lib/group_domain_models/lib/group_domain_models.dart @@ -17,6 +17,5 @@ export 'src/models/group_type.dart'; export 'src/models/member_role.dart'; export 'src/models/member.dart'; export 'src/models/school_class.dart'; -export 'src/models/school.dart'; export 'src/models/sharecode.dart'; export 'src/models/write_permissions.dart'; diff --git a/lib/group_domain_models/lib/src/models/connections_data.dart b/lib/group_domain_models/lib/src/models/connections_data.dart index 7c129a6e9..39ce0af1e 100644 --- a/lib/group_domain_models/lib/src/models/connections_data.dart +++ b/lib/group_domain_models/lib/src/models/connections_data.dart @@ -12,32 +12,22 @@ import 'package:sharezone_common/helper_functions.dart'; import 'package:sharezone_common/references.dart'; class ConnectionsData { - final School school; final Map schoolClass; final Map courses; - const ConnectionsData._( - {@required this.school, - @required this.schoolClass, - @required this.courses}); + const ConnectionsData._({@required this.schoolClass, @required this.courses}); factory ConnectionsData.fromData({@required Map data}) { if (data == null) { return const ConnectionsData._( - school: null, schoolClass: null, courses: {}, ); } - Map schools = decodeMap(data[CollectionNames.schools], - (key, data) => School.fromData(data, id: key)); Map schoolClasses = decodeMap( data[CollectionNames.schoolClasses], (key, data) => SchoolClass.fromData(data, id: key)); - School school; - if (schools.length == 1) school = schools.values.first; return ConnectionsData._( - school: school, schoolClass: schoolClasses, courses: decodeMap(data[CollectionNames.courses], (key, data) => Course.fromData(data, id: key)), @@ -53,7 +43,6 @@ class ConnectionsData { } return ConnectionsData._( schoolClass: schoolClass, - school: school, courses: courseMap, ); } diff --git a/lib/group_domain_models/lib/src/models/group_type.dart b/lib/group_domain_models/lib/src/models/group_type.dart index 5a9abbc0a..6bd64585b 100644 --- a/lib/group_domain_models/lib/src/models/group_type.dart +++ b/lib/group_domain_models/lib/src/models/group_type.dart @@ -8,7 +8,7 @@ import 'package:sharezone_common/helper_functions.dart'; -enum GroupType { course, schoolclass, school } +enum GroupType { course, schoolclass } GroupType groupTypeFromString(String data) => enumFromString(GroupType.values, data, orElse: GroupType.course); diff --git a/lib/group_domain_models/lib/src/models/school.dart b/lib/group_domain_models/lib/src/models/school.dart deleted file mode 100644 index 6261e24e6..000000000 --- a/lib/group_domain_models/lib/src/models/school.dart +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) 2022 Sharezone UG (haftungsbeschränkt) -// Licensed under the EUPL-1.2-or-later. -// -// You may obtain a copy of the Licence at: -// https://joinup.ec.europa.eu/software/page/eupl -// -// SPDX-License-Identifier: EUPL-1.2 - -import 'package:flutter/foundation.dart'; - -import 'course.dart'; -import 'member_role.dart'; - -class School { - final String id, name, publicKey, joinLink; - final MemberRole myRole; - final CourseSettings settings; - - School._({ - @required this.id, - @required this.name, - @required this.myRole, - @required this.publicKey, - @required this.settings, - @required this.joinLink, - }); - - factory School.fromData(Map data, {@required String id}) { - return School._( - id: id, - name: data['name'], - myRole: memberRoleEnumFromString(data['myRole']), - publicKey: data['publicKey'], - joinLink: data['joinLink'], - settings: CourseSettings.fromData(data['settings']), - ); - } -} - -class SchoolData { - final String id, name, title, description, abbreviation; - final String publicKey, joinLink; - final CourseSettings settings; - - const SchoolData._({ - @required this.id, - @required this.name, - @required this.title, - @required this.description, - @required this.abbreviation, - @required this.publicKey, - @required this.joinLink, - @required this.settings, - }); - - factory SchoolData.create() { - return const SchoolData._( - id: null, - name: "", - title: "", - description: "", - abbreviation: "", - publicKey: null, - joinLink: null, - settings: CourseSettings.standard, - ); - } - - factory SchoolData.fromData( - {@required String id, @required Map data}) { - return SchoolData._( - id: id, - name: data['name'], - title: data['subject'], - description: data['description'], - abbreviation: data['abbreviation'], - publicKey: data['publicKey'], - joinLink: data['joinLink'], - settings: CourseSettings.fromData(data['settings']), - ); - } - - Map toCreateJson() { - return { - 'name': name, - 'subject': title, - 'description': description, - 'abbreviation': abbreviation, - 'publicKey': publicKey, - 'joinLink': joinLink, - 'settings': settings.toJson(), - }; - } - - Map toEditJson() { - return { - 'name': name, - 'title': title, - 'description': description, - 'abbreviation': abbreviation, - 'publicKey': publicKey, - 'joinLink': joinLink, - 'settings': settings.toJson(), - }; - } - - SchoolData copyWith({ - String id, - String name, - String title, - String description, - String abbreviation, - String publicKey, - String joinLink, - CourseSettings settings, - }) { - return SchoolData._( - id: id ?? this.id, - name: name ?? this.name, - title: title ?? this.title, - description: description ?? this.description, - abbreviation: abbreviation ?? this.abbreviation, - publicKey: publicKey ?? this.publicKey, - joinLink: joinLink ?? this.joinLink, - settings: settings ?? this.settings, - ); - } -}