Skip to content

Commit

Permalink
converted private orgs to userRegistrationRequired orgs (#2322)
Browse files Browse the repository at this point in the history
* converted private orgs to userRegistrationRequired orgs

* fixed run_check_ignore
  • Loading branch information
Azad99-9 authored Jan 16, 2024
1 parent 6600086 commit 85e8432
Show file tree
Hide file tree
Showing 25 changed files with 102 additions and 105 deletions.
10 changes: 6 additions & 4 deletions lib/models/organization/org_info.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class OrgInfo {
this.description,
this.id,
this.image,
this.isPublic,
this.userRegistrationRequired,
this.name,
});

Expand All @@ -34,7 +34,9 @@ class OrgInfo {
name: json['name'] != null ? json['name'] as String? : null,
description:
json['description'] != null ? json['description'] as String? : null,
isPublic: json['isPublic'] != null ? json['isPublic'] as bool? : null,
userRegistrationRequired: json['userRegistrationRequired'] != null
? json['userRegistrationRequired'] as bool?
: null,
creatorInfo: json['creator'] != null
? User.fromJson(
json['creator'] as Map<String, dynamic>,
Expand Down Expand Up @@ -112,9 +114,9 @@ class OrgInfo {
@HiveField(5)
String? description;

/// The org visibility.
/// The org registration is required.
@HiveField(6)
bool? isPublic;
bool? userRegistrationRequired;

/// The org creatorInfo.
@HiveField(7)
Expand Down
7 changes: 2 additions & 5 deletions lib/models/organization/org_info.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import 'package:talawa/views/pre_auth_screens/select_language.dart';
import 'package:talawa/views/pre_auth_screens/select_organization.dart';
import 'package:talawa/views/pre_auth_screens/set_url.dart';
import 'package:talawa/views/pre_auth_screens/signup_details.dart';
import 'package:talawa/views/pre_auth_screens/waiting_to_join_private_org.dart';
import 'package:talawa/views/pre_auth_screens/waiting_screen.dart';

/// The MaterialApp provides us with a property called generateRoute where.
///
Expand Down
32 changes: 16 additions & 16 deletions lib/utils/queries.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -48,7 +48,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -62,7 +62,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand Down Expand Up @@ -106,7 +106,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -119,7 +119,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -133,7 +133,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand Down Expand Up @@ -207,7 +207,7 @@ class Queries {
_id
name
image
isPublic
userRegistrationRequired
creator{
firstName
lastName
Expand All @@ -229,7 +229,7 @@ class Queries {
where:{
name_starts_with: \$nameStartsWith,
visibleInSearch: true,
isPublic: true,
userRegistrationRequired: true,
}
first: \$first,
skip: \$skip,
Expand All @@ -239,7 +239,7 @@ class Queries {
_id
name
image
isPublic
userRegistrationRequired
creator{
firstName
lastName
Expand All @@ -266,7 +266,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand Down Expand Up @@ -297,7 +297,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -324,7 +324,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -338,7 +338,7 @@ class Queries {
name
image
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand All @@ -351,7 +351,7 @@ class Queries {
_id
name
image
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand Down Expand Up @@ -420,7 +420,7 @@ class Queries {
_id
name
image
isPublic
userRegistrationRequired
creator{
firstName
lastName
Expand Down Expand Up @@ -480,7 +480,7 @@ class Queries {
_id
}
description
isPublic
userRegistrationRequired
creator{
_id
firstName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,8 @@ class SelectOrganizationViewModel extends BaseModel {
selectedOrganization = item;
notifyListeners();
onTapJoin();
// print(selectedOrganization.isPublic);

if (!selectedOrganization.isPublic!) {
if (selectedOrganization.userRegistrationRequired!) {
navigationService.pushScreen(
Routes.requestAccess,
arguments: selectedOrganization,
Expand Down Expand Up @@ -186,8 +185,8 @@ class SelectOrganizationViewModel extends BaseModel {
/// **returns**:
/// * `Future<void>`: None
Future<void> onTapJoin() async {
// if `selectedOrganization` is public.
if (selectedOrganization.isPublic == true) {
// if `selectedOrganization` registrations is not required.
if (selectedOrganization.userRegistrationRequired == false) {
try {
// run the graph QL mutation
final QueryResult result = await databaseFunctions.gqlAuthMutation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ class SignupDetailsViewModel extends BaseModel {
final bool tokenRefreshed = await graphqlConfig.getToken() as bool;
// if user successfully saved and access token is also generated.
if (userSaved && tokenRefreshed) {
// if the selected organization is public.
if (selectedOrganization.isPublic!) {
// if the selected organization userRegistration not required.
if (!selectedOrganization.userRegistrationRequired!) {
try {
final QueryResult result =
await databaseFunctions.gqlAuthMutation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
// ignore_for_file: talawa_api_doc
// ignore_for_file: talawa_good_doc_comments

import 'package:flutter/material.dart';
import 'package:talawa/enums/enums.dart';
import 'package:talawa/services/size_config.dart';
Expand All @@ -12,7 +9,7 @@ import 'package:talawa/widgets/raised_round_edge_button.dart';
import 'package:talawa/widgets/rich_text.dart';
import 'package:talawa/widgets/signup_progress_indicator.dart';

/// This class returns a widget which shows the request sent by the user to join a private organization.
/// Displays a screen instructing the user to wait for approval.
class WaitingPage extends StatelessWidget {
const WaitingPage({super.key});

Expand Down
6 changes: 4 additions & 2 deletions lib/widgets/custom_list_tile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ class CustomListTile extends StatelessWidget {
child: type != TileType.user
? type == TileType.org
? Icon(
orgInfo!.isPublic! ? Icons.lock_open : Icons.lock,
color: orgInfo!.isPublic!
!orgInfo!.userRegistrationRequired!
? Icons.lock_open
: Icons.lock,
color: !orgInfo!.userRegistrationRequired!
? const Color(0xFF34AD64)
: const Color(0xffFABC57),
)
Expand Down
10 changes: 5 additions & 5 deletions test/helpers/test_helpers.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ final fakeOrgInfo = OrgInfo(
firstName: "ravidi",
lastName: "shaikh",
),
isPublic: false,
userRegistrationRequired: true,
);

void _removeRegistrationIfExists<T extends Object>() {
Expand Down Expand Up @@ -363,13 +363,13 @@ UserConfig getAndRegisterUserConfig() {
OrgInfo(
id: '3',
name: 'test org 3',
isPublic: true,
userRegistrationRequired: false,
creatorInfo: User(firstName: 'test', lastName: '1'),
),
OrgInfo(
id: '4',
name: 'test org 4',
isPublic: false,
userRegistrationRequired: true,
creatorInfo: User(firstName: 'test', lastName: '2'),
),
OrgInfo(
Expand All @@ -381,13 +381,13 @@ UserConfig getAndRegisterUserConfig() {
OrgInfo(
id: '1',
name: 'test org',
isPublic: false,
userRegistrationRequired: true,
creatorInfo: User(firstName: 'test', lastName: 'test'),
),
OrgInfo(
id: '2',
name: 'test org',
isPublic: false,
userRegistrationRequired: true,
creatorInfo: User(firstName: 'test', lastName: 'test'),
),
],
Expand Down
16 changes: 8 additions & 8 deletions test/model_tests/organization/org_info_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void main() {
'image': 'image_url',
'name': 'Name',
'description': 'Description',
'isPublic': true,
'userRegistrationRequired': false,
'creator': userJson,
'members': [userJson],
'admins': [userJson],
Expand All @@ -26,7 +26,7 @@ void main() {
'image': 'image_url',
'name': 'Name',
'description': 'Description',
'isPublic': true,
'userRegistrationRequired': false,
'creator': userJson,
'members': [userJson],
'admins': [userJson],
Expand All @@ -39,7 +39,7 @@ void main() {
expect(result.image, 'image_url');
expect(result.name, 'Name');
expect(result.description, 'Description');
expect(result.isPublic, true);
expect(result.userRegistrationRequired, false);
expect(result.creatorInfo!.authToken, ' ');
expect(result.creatorInfo!.refreshToken, ' ');
expect(result.creatorInfo!.id, 'user_id');
Expand All @@ -64,7 +64,7 @@ void main() {
expect(result.image, 'image_url');
expect(result.name, 'Name');
expect(result.description, 'Description');
expect(result.isPublic, true);
expect(result.userRegistrationRequired, false);
expect(result.creatorInfo!.authToken, ' ');
expect(result.creatorInfo!.refreshToken, ' ');
expect(result.creatorInfo!.id, 'user_id');
Expand Down Expand Up @@ -92,7 +92,7 @@ void main() {
expect(result.image, 'image_url');
expect(result.name, 'Name');
expect(result.description, 'Description');
expect(result.isPublic, true);
expect(result.userRegistrationRequired, false);
expect(result.creatorInfo!.authToken, ' ');
expect(result.creatorInfo!.refreshToken, ' ');
expect(result.creatorInfo!.id, 'user_id');
Expand Down Expand Up @@ -124,7 +124,7 @@ void main() {
expect(res[0].image, 'image_url');
expect(res[0].name, 'Name');
expect(res[0].description, 'Description');
expect(res[0].isPublic, true);
expect(res[0].userRegistrationRequired, false);
expect(res[0].creatorInfo!.authToken, ' ');
expect(res[0].creatorInfo!.refreshToken, ' ');
expect(res[0].creatorInfo!.id, 'user_id');
Expand All @@ -141,7 +141,7 @@ void main() {
expect(res[1].image, 'image_url');
expect(res[1].name, 'Name');
expect(res[1].description, 'Description');
expect(res[1].isPublic, true);
expect(res[1].userRegistrationRequired, false);
expect(res[1].creatorInfo!.authToken, ' ');
expect(res[1].creatorInfo!.refreshToken, ' ');
expect(res[1].creatorInfo!.id, 'user_id');
Expand All @@ -158,7 +158,7 @@ void main() {
expect(res[2].image, 'image_url');
expect(res[2].name, 'Name');
expect(res[2].description, 'Description');
expect(res[2].isPublic, true);
expect(res[2].userRegistrationRequired, false);
expect(res[2].creatorInfo!.authToken, ' ');
expect(res[2].creatorInfo!.refreshToken, ' ');
expect(res[2].creatorInfo!.id, 'user_id');
Expand Down
Loading

0 comments on commit 85e8432

Please sign in to comment.