Skip to content
Snippets Groups Projects

Add settings for user permission defaults

Merged gitlab-qa-bot requested to merge github/fork/dmedvinsky/add-defaults-create-group-team into master

Created by: dmedvinsky

“Can create groups” and “Can create teams” had hardcoded defaults to true. Sometimes it is desirable to prohibit these for newly created users by default.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
48 48 # GitLab
49 49 #
50 50 Settings['gitlab'] ||= Settingslogic.new({})
51 Settings.gitlab['default_projects_limit'] ||= 10
51 Settings.gitlab['default_projects_limit'] ||= 10
52 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil?
  • Created by: jouve

    That will always set Settings.gitlab['default_can_create_group']to true use

    Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil?

    instead.

    By Administrator on 2013-05-16T14:03:22 (imported from GitLab project)

    By Administrator on 2013-05-16T14:03:22 (imported from GitLab)

  • gitlab-qa-bot
  • 48 48 # GitLab
    49 49 #
    50 50 Settings['gitlab'] ||= Settingslogic.new({})
    51 Settings.gitlab['default_projects_limit'] ||= 10
    51 Settings.gitlab['default_projects_limit'] ||= 10
    52 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil?
    53 Settings.gitlab['default_can_create_team'] = true if Settings.gitlab['default_can_create_team'].nil?
    • Created by: jouve

      Same here.

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab project)

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab)

  • gitlab-qa-bot
  • 48 48 # GitLab
    49 49 #
    50 50 Settings['gitlab'] ||= Settingslogic.new({})
    51 Settings.gitlab['default_projects_limit'] ||= 10
    51 Settings.gitlab['default_projects_limit'] ||= 10
    52 Settings.gitlab['default_can_create_group'] = true if Settings.gitlab['default_can_create_group'].nil?
    • Created by: dmedvinsky

      Oh, shame on me for a silly copy-paste. :confused:

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab project)

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab)

  • Created by: dmedvinsky

    Fixed as per @jouve's comment (thanks!) and rebased to latest master.

    By Administrator on 2013-03-13T06:32:33 (imported from GitLab project)

    By Administrator on 2013-03-13T06:32:33 (imported from GitLab)

  • Created by: coveralls

    Coverage decreased (-0.09%) when pulling 30ea2b6c66f0768afc9956aefa319c4a7ba5f044 on dmedvinsky:add-defaults-create-group-team into 366bc320 on gitlabhq:master.

    View Details

    By Administrator on 2013-03-13T06:59:39 (imported from GitLab project)

    By Administrator on 2013-03-13T06:59:39 (imported from GitLab)

  • gitlab-qa-bot
  • Unable to load the diff
    • Created by: raphendyr

      Is this line now twice?

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab project)

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab)

  • gitlab-qa-bot
  • Unable to load the diff
    • Created by: dmedvinsky

      No idea how that happened. :dizzy_face:

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab project)

      By Administrator on 2013-05-16T14:03:22 (imported from GitLab)

  • Created by: coveralls

    Coverage remained the same when pulling 1cd3c64579119883e0aef94d35688d6a296a8a69 on dmedvinsky:add-defaults-create-group-team into 366bc320 on gitlabhq:master.

    View Details

    By Administrator on 2013-03-13T09:52:38 (imported from GitLab project)

    By Administrator on 2013-03-13T09:52:38 (imported from GitLab)

  • Created by: raphendyr

    @randx Is there some reason that this PR is not merged? I would like to have this in our server (without cherry-picking/merging my self)...

    By Administrator on 2013-03-28T10:11:19 (imported from GitLab project)

    By Administrator on 2013-03-28T10:11:19 (imported from GitLab)

  • Created by: raphendyr

    Btw. Could it be done in app/model/user.rb in a way like this:

    before_save :default_values
    
    private 
    
    def default_values 
      self.can_create_group = Gitlab.config.gitlab.default_can_create_group if self.can_create_group.nil?
      self.can_create_team = Gitlab.config.gitlab.default_can_create_team if self.can_create_team.nil?
      self.projects_limit = Gitlab.config.gitlab.default_projects_limit if self.projects_limit.nil?
      # and so on...
    end

    maybe this is even bit better:

    before_save :default_values, on: :create

    This would be bit more logical (at least for me) to add all default values in model instead of authentication.

    EDIT: Oh. When reading more from the net, I found out that using before_create :default_values might be better. I do not know myself.

    By Administrator on 2013-03-28T10:32:01 (imported from GitLab project)

    By Administrator on 2013-03-28T10:32:01 (imported from GitLab)

  • Created by: dmedvinsky

    If @randx thinks what @raphendyr suggested is a way to do it (and maybe that's what's preventing this from being merged), I can refactor this, not a problem.

    By Administrator on 2013-03-28T11:18:32 (imported from GitLab project)

    By Administrator on 2013-03-28T11:18:32 (imported from GitLab)

  • Created by: dzaporozhets

    Since we have default db values we'll never get nil in self.can_create_team.nil? So we cannot rely on model hook.

    Also take a look at https://github.com/gitlabhq/gitlabhq/blob/master/app/controllers/registrations_controller.rb#L19 since we have optional signup.

    I think the best way is to define something @user = User.new.with_defaults and use it in lib/auth, registration controller and admin controller(action: new)

    By Administrator on 2013-04-07T18:30:44 (imported from GitLab project)

    By Administrator on 2013-04-07T18:30:44 (imported from GitLab)

  • Created by: dzaporozhets

    @dmedvinsky can you proceed with this PR?

    By Administrator on 2013-05-07T14:00:59 (imported from GitLab project)

    By Administrator on 2013-05-07T14:00:59 (imported from GitLab)

  • Created by: dmedvinsky

    Sure, I hope to take a look the next week.

    By Administrator on 2013-05-10T07:25:18 (imported from GitLab project)

    By Administrator on 2013-05-10T07:25:18 (imported from GitLab)

  • Created by: dmedvinsky

    Pushed a new version. Hopefully this is what you meant. I'm only unsure about that test settings thingy in config/initializers. Is there a better way to provide test settings?

    By Administrator on 2013-05-16T14:07:11 (imported from GitLab project)

    By Administrator on 2013-05-16T14:07:11 (imported from GitLab)

  • Created by: coveralls

    Coverage Status

    Coverage decreased (-0%) when pulling 22279bc5 on dmedvinsky:add-defaults-create-group-team into 8cfc6a4d on gitlabhq:master.

    By Administrator on 2013-05-16T14:30:50 (imported from GitLab project)

    By Administrator on 2013-05-16T14:30:50 (imported from GitLab)

  • Created by: dzaporozhets

    @dmedvinsky :thumbsup: merged

    By Administrator on 2013-05-27T12:18:24 (imported from GitLab project)

    By Administrator on 2013-05-27T12:18:24 (imported from GitLab)

  • Please register or sign in to reply
    Loading