-
-
Notifications
You must be signed in to change notification settings - Fork 506
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Fundraising Campaigns (GSoC) (#2635)
* Fundraising Campaigns * adding tests * adding tests * adding tests * adding tests * adding tests * adding tests * adding tests
- Loading branch information
Showing
40 changed files
with
6,140 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
import 'package:talawa/models/funds/fund_campaign.dart'; | ||
import 'package:talawa/models/user/user_info.dart'; | ||
|
||
/// The `Fund` class represents a fund in the application. | ||
class Fund { | ||
/// Constructs a `Fund` instance. | ||
/// | ||
/// [id] is the unique identifier of the fund. | ||
/// [organizationId] is the identifier of the organization to which the fund belongs. | ||
/// [name] is the name of the fund. | ||
/// [taxDeductible] indicates whether the fund is tax-deductible. | ||
/// [isDefault] indicates whether the fund is the default fund. | ||
/// [isArchived] indicates whether the fund is archived. | ||
/// [creatorId] is the identifier of the user who created the fund. | ||
/// [campaigns] is a list of campaign identifiers associated with the fund. | ||
/// [createdAt] is the timestamp of when the fund was created. | ||
/// [updatedAt] is the timestamp of when the fund was last updated. | ||
Fund({ | ||
this.id, | ||
this.organizationId, | ||
this.name, | ||
this.taxDeductible, | ||
this.isDefault, | ||
this.isArchived, | ||
this.creator, | ||
this.campaigns, | ||
this.createdAt, | ||
this.updatedAt, | ||
}); | ||
|
||
/// Creates a `Fund` instance from a JSON object. | ||
/// | ||
/// The [json] parameter is a map containing the fund data. | ||
/// | ||
/// Returns an instance of `Fund`. | ||
factory Fund.fromJson(Map<String, dynamic> json) { | ||
return Fund( | ||
id: json['_id'] as String?, | ||
organizationId: json['organizationId'] as String?, | ||
name: json['name'] as String?, | ||
taxDeductible: json['taxDeductible'] as bool?, | ||
isDefault: json['isDefault'] as bool?, | ||
isArchived: json['isArchived'] as bool?, | ||
creator: json['creator'] == null | ||
? null | ||
: User.fromJson( | ||
json['creator'] as Map<String, dynamic>, | ||
fromOrg: true, | ||
), | ||
campaigns: (json['campaigns'] as List<dynamic>?) | ||
?.map((e) => e as Campaign) | ||
.toList(), | ||
createdAt: json['createdAt'] != null | ||
? DateTime.parse(json['createdAt'] as String) | ||
: null, | ||
updatedAt: json['updatedAt'] != null | ||
? DateTime.parse(json['updatedAt'] as String) | ||
: null, | ||
); | ||
} | ||
|
||
/// The unique identifier of the fund. | ||
final String? id; | ||
|
||
/// The identifier of the organization to which the fund belongs. | ||
final String? organizationId; | ||
|
||
/// The name of the fund. | ||
final String? name; | ||
|
||
/// Indicates whether the fund is tax-deductible. | ||
final bool? taxDeductible; | ||
|
||
/// Indicates whether the fund is the default fund. | ||
final bool? isDefault; | ||
|
||
/// Indicates whether the fund is archived. | ||
final bool? isArchived; | ||
|
||
/// The identifier of the user who created the fund. | ||
final User? creator; | ||
|
||
/// A list of campaign identifiers associated with the fund. | ||
final List<Campaign>? campaigns; | ||
|
||
/// The timestamp of when the fund was created. | ||
final DateTime? createdAt; | ||
|
||
/// The timestamp of when the fund was last updated. | ||
final DateTime? updatedAt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:talawa/models/funds/fund_pledges.dart'; | ||
|
||
/// The `Campaign` class represents a fundraising campaign in the application. | ||
class Campaign { | ||
/// Constructs a `FundraisingCampaign` instance. | ||
/// | ||
/// [id] is the unique identifier of the campaign. | ||
/// [fundId] is the identifier of the fund to which the campaign belongs. | ||
/// [name] is the name of the campaign. | ||
/// [startDate] is the start date of the campaign. | ||
/// [endDate] is the end date of the campaign. | ||
/// [fundingGoal] is the funding goal of the campaign. | ||
/// [currency] is the currency used for the campaign. | ||
/// [pledges] is a list of pledge identifiers associated with the campaign. | ||
/// [createdAt] is the timestamp of when the campaign was created. | ||
/// [updatedAt] is the timestamp of when the campaign was last updated. | ||
Campaign({ | ||
this.id, | ||
this.fundId, | ||
this.name, | ||
this.startDate, | ||
this.endDate, | ||
this.fundingGoal, | ||
this.currency, | ||
this.pledges, | ||
this.createdAt, | ||
this.updatedAt, | ||
}); | ||
|
||
/// Creates a `Campaign` instance from a JSON object. | ||
/// | ||
/// The [json] parameter is a map containing the campaign data. | ||
/// | ||
/// Returns an instance of `Campaign`. | ||
factory Campaign.fromJson(Map<String, dynamic> json) { | ||
return Campaign( | ||
id: json['_id'] as String?, | ||
fundId: json['fundId'] as String?, | ||
name: json['name'] as String?, | ||
startDate: json['startDate'] != null | ||
? DateTime.parse(json['startDate'] as String) | ||
: null, | ||
endDate: json['endDate'] != null | ||
? DateTime.parse(json['endDate'] as String) | ||
: null, | ||
fundingGoal: (json['fundingGoal'] is int) | ||
? (json['fundingGoal'] as int).toDouble() | ||
: json['fundingGoal'] as double?, | ||
currency: json['currency'] as String?, | ||
pledges: | ||
(json['pledges'] as List<dynamic>?)?.map((e) => e as Pledge).toList(), | ||
createdAt: json['createdAt'] != null | ||
? DateTime.parse(json['createdAt'] as String) | ||
: null, | ||
updatedAt: json['updatedAt'] != null | ||
? DateTime.parse(json['updatedAt'] as String) | ||
: null, | ||
); | ||
} | ||
|
||
/// The unique identifier of the campaign. | ||
final String? id; | ||
|
||
/// The identifier of the fund to which the campaign belongs. | ||
final String? fundId; | ||
|
||
/// The name of the campaign. | ||
final String? name; | ||
|
||
/// The start date of the campaign. | ||
final DateTime? startDate; | ||
|
||
/// The end date of the campaign. | ||
final DateTime? endDate; | ||
|
||
/// The funding goal of the campaign. | ||
final double? fundingGoal; | ||
|
||
/// The currency used for the campaign. | ||
final String? currency; | ||
|
||
/// A list of pledge identifiers associated with the campaign. | ||
final List<Pledge>? pledges; | ||
|
||
/// The timestamp of when the campaign was created. | ||
final DateTime? createdAt; | ||
|
||
/// The timestamp of when the campaign was last updated. | ||
final DateTime? updatedAt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import 'package:talawa/models/funds/fund_campaign.dart'; | ||
import 'package:talawa/models/user/user_info.dart'; | ||
|
||
/// The `Pledge` class represents a pledge for a fundraising campaign in the application. | ||
class Pledge { | ||
/// Constructs a `Pledge` instance. | ||
/// | ||
/// [id] is the unique identifier of the pledge. | ||
/// [campaigns] is a list of campaign identifiers associated with the pledge. | ||
/// [users] is a list of user identifiers associated with the pledge. | ||
/// [startDate] is the start date of the pledge. | ||
/// [endDate] is the end date of the pledge. | ||
/// [amount] is the amount pledged. | ||
/// [currency] is the currency of the pledged amount. | ||
/// [createdAt] is the timestamp of when the pledge was created. | ||
/// [updatedAt] is the timestamp of when the pledge was last updated. | ||
Pledge({ | ||
this.id, | ||
this.campaigns, | ||
this.pledgers, | ||
this.startDate, | ||
this.endDate, | ||
this.amount, | ||
this.currency, | ||
this.createdAt, | ||
this.updatedAt, | ||
}); | ||
|
||
/// Creates a `Pledge` instance from a JSON object. | ||
/// | ||
/// The [json] parameter is a map containing the pledge data. | ||
/// | ||
/// Returns an instance of `Pledge`. | ||
factory Pledge.fromJson(Map<String, dynamic> json) { | ||
return Pledge( | ||
id: json['_id'] as String?, | ||
campaigns: (json['campaigns'] as List<dynamic>?) | ||
?.map((e) => e as Campaign) | ||
.toList(), | ||
pledgers: json['users'] == null | ||
? null | ||
: (json['users'] as List<dynamic>?) | ||
?.map( | ||
(e) => User.fromJson(e as Map<String, dynamic>, fromOrg: true), | ||
) | ||
.toList(), | ||
startDate: json['startDate'] != null | ||
? DateTime.parse(json['startDate'] as String) | ||
: null, | ||
endDate: json['endDate'] != null | ||
? DateTime.parse(json['endDate'] as String) | ||
: null, | ||
amount: json['amount'] as int?, | ||
currency: json['currency'] as String?, | ||
createdAt: json['createdAt'] != null | ||
? DateTime.parse(json['createdAt'] as String) | ||
: null, | ||
updatedAt: json['updatedAt'] != null | ||
? DateTime.parse(json['updatedAt'] as String) | ||
: null, | ||
); | ||
} | ||
|
||
/// The unique identifier of the pledge. | ||
final String? id; | ||
|
||
/// A list of campaign identifiers associated with the pledge. | ||
final List<Campaign>? campaigns; | ||
|
||
/// A list of user identifiers associated with the pledge. | ||
final List<User>? pledgers; | ||
|
||
/// The start date of the pledge. | ||
final DateTime? startDate; | ||
|
||
/// The end date of the pledge. | ||
final DateTime? endDate; | ||
|
||
/// The amount pledged. | ||
final int? amount; | ||
|
||
/// The currency of the pledged amount. | ||
final String? currency; | ||
|
||
/// The timestamp of when the pledge was created. | ||
final DateTime? createdAt; | ||
|
||
/// The timestamp of when the pledge was last updated. | ||
final DateTime? updatedAt; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.