@@ -79,6 +79,45 @@ def output(self, data):
7979 return UserDict (data )
8080
8181
82+ class PrAuthorsOptions (fields .Dict ):
83+ BYPASS_LIST = [
84+ 'bypass_author_approval' ,
85+ 'bypass_jira_check' ,
86+ 'bypass_build_status' ,
87+ 'bypass_commit_size' ,
88+ 'bypass_incompatible_branch' ,
89+ 'bypass_peer_approval' ,
90+ 'bypass_leader_approval' ,
91+ ]
92+
93+ def serialize (self , value , attr = None , obj = None ):
94+ data = super (PrAuthorsOptions , self ).serialize (value , attr , obj )
95+ res = dict ()
96+ for user , values in data .items ():
97+ res [user ] = [key for key , value in data .items () if value ]
98+
99+ return res
100+
101+ def deserialize (self , value , attr = None , data = None ):
102+ data = super (PrAuthorsOptions , self ).deserialize (value , attr , data )
103+
104+ found_elem = []
105+ res = dict ()
106+ for user , bypass_list in data .items ():
107+ for elem in bypass_list :
108+ if elem in self .BYPASS_LIST :
109+ found_elem .append (elem )
110+ else :
111+ raise IncorrectSettingsFile (
112+ f'This bypass does not exist: { elem } '
113+ )
114+
115+ res [user ] = dict ([
116+ (key , key in bypass_list ) for key in self .BYPASS_LIST
117+ ])
118+ return res
119+
120+
82121class SettingsSchema (Schema ):
83122 # Settings defined in config files
84123 always_create_integration_pull_requests = fields .Bool (missing = True )
@@ -100,6 +139,7 @@ class SettingsSchema(Schema):
100139 need_author_approval = fields .Bool (missing = True )
101140 required_leader_approvals = fields .Int (missing = 0 )
102141 required_peer_approvals = fields .Int (missing = 2 )
142+ pr_author_options = PrAuthorsOptions (missing = {})
103143
104144 jira_account_url = fields .Str (missing = '' )
105145 jira_email = fields .Str (missing = '' )
0 commit comments