@@ -80,15 +80,27 @@ def update_product_access(backend, uid, user=None, social=None, *args, **kwargs)
80
80
# Create product_type if necessary
81
81
product_type , created = Product_Type .objects .get_or_create (name = 'Gitlab Import' )
82
82
# For each project: create a new product or update product's authorized_users
83
- for project_name in project_names :
84
- if project_name not in user_product_names :
83
+ for project in projects :
84
+ if project . path_with_namespace not in user_product_names :
85
85
# Create new product
86
- product , created = Product .objects .get_or_create (name = project_name , prod_type = product_type )
86
+ product , created = Product .objects .get_or_create (name = project . path_with_namespace , prod_type = product_type )
87
87
if not settings .FEATURE_AUTHORIZATION_V2 :
88
88
product .authorized_users .add (user )
89
89
product .save ()
90
90
else :
91
91
product_member , created = Product_Member .objects .get_or_create (product = product , user = user , defaults = {'role' : Role .objects .get (id = Roles .Owner )})
92
+ # Import tags and/orl URL if necessary
93
+ if settings .GITLAB_PROJECT_IMPORT_TAGS :
94
+ if hasattr (project , 'topics' ):
95
+ if len (project .topics ) > 0 :
96
+ product .tags = "," .join (project .topics )
97
+ elif hasattr (project , 'tag_list' ) and len (project .tag_list ) > 0 :
98
+ product .tags = "," .join (project .tag_list )
99
+ if settings .GITLAB_PROJECT_IMPORT_URL :
100
+ if hasattr (project , 'web_url' ) and len (project .web_url ) > 0 :
101
+ product .description = "[" + project .web_url + "](" + project .web_url + ")"
102
+ if settings .GITLAB_PROJECT_IMPORT_TAGS or settings .GITLAB_PROJECT_IMPORT_URL :
103
+ product .save ()
92
104
93
105
# For each product: if user is not project member any more, remove him from product's authorized users
94
106
for product_name in user_product_names :
0 commit comments