Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite069fb6

Browse files
committed
Add docstrings to use cases
1 parent29d3593 commite069fb6

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

‎sponsors/use_cases.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
"""
2+
This module holds Use Cases (UCs) implementations. These are indirections to trigger business rules
3+
and avoid the sponsors core logic and state management to be spread across views codes.
4+
"""
15
fromabcimportABC,abstractmethod
26

37
fromsponsorsimportnotifications
@@ -6,14 +10,24 @@
610

711

812
classBaseUseCaseWithNotifications(ABC):
13+
"""
14+
Abstract base class to be used to implement use cases.
15+
It holds a list of notifications to be dispatched by the UC if needed
16+
"""
917
notifications= []
1018

1119
@classmethod
1220
defbuild(cls):
21+
"""
22+
Factory method to explicity handle complex logic and/or dependency injection
23+
"""
1324
returncls(cls.notifications)
1425

1526
@abstractmethod
1627
defexecute(self,*args,**kwargs):
28+
"""
29+
Abstract method to implement specific UC business rules
30+
"""
1731
pass
1832

1933
def__init__(self,notifications):
@@ -25,6 +39,10 @@ def notify(self, **kwargs):
2539

2640

2741
classCreateSponsorshipApplicationUseCase(BaseUseCaseWithNotifications):
42+
"""
43+
Use case called to create a new sponsorships application for submitted by a user
44+
"""
45+
2846
notifications= [
2947
notifications.AppliedSponsorshipNotificationToPSF(),
3048
notifications.AppliedSponsorshipNotificationToSponsors(),
@@ -37,6 +55,9 @@ def execute(self, user, sponsor, benefits, package=None, request=None):
3755

3856

3957
classRejectSponsorshipApplicationUseCase(BaseUseCaseWithNotifications):
58+
"""
59+
Use case to enable PSF staff to reject an application
60+
"""
4061
notifications= [
4162
notifications.RejectedSponsorshipNotificationToPSF(),
4263
notifications.RejectedSponsorshipNotificationToSponsors(),
@@ -50,6 +71,9 @@ def execute(self, sponsorship, request=None):
5071

5172

5273
classApproveSponsorshipApplicationUseCase(BaseUseCaseWithNotifications):
74+
"""
75+
Use case to enable PSF staff to approve an application
76+
"""
5377
notifications= [
5478
notifications.SponsorshipApprovalLogger(),
5579
]
@@ -77,6 +101,10 @@ def execute(self, sponsorship, start_date, end_date, **kwargs):
77101

78102

79103
classSendContractUseCase(BaseUseCaseWithNotifications):
104+
"""
105+
Use case to enable PSF staff to generate the contract .docx
106+
file and sent it over email
107+
"""
80108
notifications= [
81109
notifications.ContractNotificationToPSF(),
82110
# TODO: sponsor's notification will be enabled again once
@@ -98,6 +126,14 @@ def execute(self, contract, **kwargs):
98126

99127

100128
classExecuteExistingContractUseCase(BaseUseCaseWithNotifications):
129+
"""
130+
Use case to PSF Staff to finalize a sponsorship by "executing" a contract.
131+
This UC was created to enable to enable to upload existing contracts documents
132+
that weren't generated by the sponsors app.
133+
134+
It's probable that this UC will become a legacy one once all the new
135+
contracts and sponsorships were created via the Django application
136+
"""
101137
notifications= [
102138
notifications.ExecutedExistingContractLogger(),
103139
]
@@ -113,13 +149,22 @@ def execute(self, contract, contract_file, **kwargs):
113149

114150

115151
classExecuteContractUseCase(ExecuteExistingContractUseCase):
152+
"""
153+
Use case to PSF Staff to execute a contract created by the sponsors app.
154+
Execute a contract requires the admin user to upload the signed contract
155+
and this will flag the contract as Executed and the corresponding Sponsorship
156+
as Finalized.
157+
"""
116158
notifications= [
117159
notifications.ExecutedContractLogger(),
118160
]
119161
force_execute=False
120162

121163

122164
classNullifyContractUseCase(BaseUseCaseWithNotifications):
165+
"""
166+
Use case to enable PSF staff to nullify non-executed contracts
167+
"""
123168
notifications= [
124169
notifications.NullifiedContractLogger(),
125170
]
@@ -133,6 +178,10 @@ def execute(self, contract, **kwargs):
133178

134179

135180
classSendSponsorshipNotificationUseCase(BaseUseCaseWithNotifications):
181+
"""
182+
Use case to enable PSF staff to send DB stored email notifications
183+
to a list of selected sponsorships.
184+
"""
136185
notifications= [
137186
notifications.SendSponsorNotificationLogger(),
138187
]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp