Skip to content

Added logic for gitlab account request creation to deal with multiple requests, pending vs rejected, etc.

MariaV requested to merge double_acc_rec into master

Previous version of GitlabAccountRequest view used an option one-to-one field keyed to UserIdentifier. Realized that this would mean that users who had a REJECTED request wouldn't then be able to create a new, fixed request (e.g., if a request was rejected for "need more information in comment"--the user could not then make a new, better request with more information, because the one-to-one key would reject with a DatabaseIntegrityError as there already is a GitlabAccountRequest.)

Instead, GitlabAccountRequest model has an optional ForeignKey to user. Made migrations.

CreateGitlabAccountRequestView now does the following:

1.) If user string passed in view kwargs, run validator to make sure it is a valid user_identifier pattern. If it fails, return redirect to 'user-login-error'.

2.) Else, try to retrieve that user from database. If exception-ObjectDoesNotExist, user is created, saved, and then the gitlabaccountrequest is created and saved with status pending.

3.) If the user exists, view pulls all GitlabAccountRequests and filters by user=linked_user. If len list != 0, check all requests to see if any have a pending reviewer status. If so, return a redirect to a view that explains this objects cannot be created, as the user already has a pending request. If form gets through all requests in list without redirecting, create the new gitlab account request with status of pending.

4.) If there is no user_identifier argument passed in url, just create the request without the linked_user field to user_identifier, and save as status pending.

Merge request reports

Loading