File tree Expand file tree Collapse file tree 3 files changed +11
-7
lines changed
Expand file tree Collapse file tree 3 files changed +11
-7
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,8 @@ def get_absolute_url(self):
3535 @property
3636 def provider (self ):
3737 plugins = (
38- Plugin .objects
39- .for_context (plugin_type = "issue_provider" , project = self .project )
40- .filter (uri_path__contains = self .provider_key )
38+ Plugin .objects .for_context (
39+ plugin_type = "issue_provider" , project = self .project , format = self .provider_key )
4140 )
4241 if plugins .exists ():
4342 return plugins .first ().initialize_class ()
@@ -51,6 +50,8 @@ def get_option_value(self, key):
5150 return None
5251
5352 def save_options (self , options ):
53+ if self .provider is None :
54+ raise ValueError (_ ('The provider key is required.' ))
5455 for field in self .provider .fields :
5556 try :
5657 integration_option = IntegrationOption .objects .get (integration = self , key = field .get ('key' ))
Original file line number Diff line number Diff line change @@ -37,8 +37,10 @@ def get_form_kwargs(self):
3737 def get_context_data (self , ** kwargs ):
3838 plugins = (
3939 Plugin .objects
40- .for_context (plugin_type = "issue_provider" , project = self .project , user = self .request .user )
41- .filter (uri_path__contains = self .provider_key )
40+ .for_context (
41+ plugin_type = "project_issue_provider" , project = self .project ,
42+ user = self .request .user ,format = self .provider_key
43+ )
4244 )
4345 kwargs ['provider' ] = plugins .first ().initialize_class () if plugins else None
4446 return super ().get_context_data (** kwargs )
Original file line number Diff line number Diff line change 11from rest_framework .serializers import ValidationError
22
3- from rdmo .config .plugins import get_plugin
3+ from rdmo .config .models import Plugin
44
55
66class ProviderValidator :
77
88 def __call__ (self , data ):
99 provider_key = data .get ('provider_key' )
10- provider = get_plugin ('PROJECT_ISSUE_PROVIDERS' , provider_key )
10+ plugins = Plugin .objects .for_context (plugin_type = 'project_issue_provider' , format = provider_key )
11+ provider = plugins .first ().initialize_class () if plugins else None
1112 if provider is None :
1213 raise ValidationError ({
1314 'provider_key' : 'Please provide a valid provider.'
You can’t perform that action at this time.
0 commit comments