Skip to content

Group membership and pending membership management #36

Open

Description

@tsov

straight to the point:

we need...

1. two nested resources inside the groups resource

resources :groups do
  resources :members, :controller => 'group_members' # GroupMembersController
  resources :invited, :controller => 'pending_members' # PendingMembersController
end

2. two controllers

# app/controllers/group_members_controller.rb

module Api
  module V1
    class GroupMembersController < BaseController

      def index
        # GET /groups/:id/members
        #
        # Shows all the current members of this group
      end

      def create
        # POST /groups/:id/members
        #
        # Creates a new member for this group
        # IF this user is a pending member of this group
      end

      def destroy
        # DELETE /groups/:id/members
        #
        # Deletes a member from this group
      end

    end
  end
end
# app/controllers/pending_members_controller.rb

module Api
  module V1
    class PendingMembersController < BaseController

      def index
        # GET /groups/:id/invited
        #
        # Shows all the invited users of this group
      end

      def create
        # POST /groups/:id/invited
        #
        # Invites a user to this group
        # IF the currently logged in user is a member of this group
        # AND the invited user is NOT already a pending member OR current member of this group
      end

      def destroy
        # DELETE /groups/:id/members
        #
        # Deletes the invitations
      end

    end
  end
end

Activity

  1. ghost assigned on Jul 8, 2013
  2. tsov commented on Jul 8, 2013

    @tsov
    ContributorAuthor

    update! I just edited the issue

  3. foFox commented on Jul 9, 2013

    @foFox
    Member

    About that

      def create
        # POST /groups/:id/members
        #
        # Creates a new member for this group
        # IF this user is a pending member of this group
      end
    

    I think this creates sort of a feeling that you can create a member directly. where this is not true. You can only invite someone, and that someone, can accept the invitation.

    I think if we go ahead and say that to accept the invitation, you go to PUT /groups/:id/invited and send accepted=true / accepted=false this will be better.
    Then a the user moved form invited to members or deleted from invited.
    I think it's bit more concise with what's actually going on.
    What do you think ?

    We can make it so you can delete the invitation, with the delete, if it's been sent already but user hasn't got a change to accept it.

  4. tsov commented on Jul 9, 2013

    @tsov
    ContributorAuthor

    Ok sounds like a good idea too, but the idea was that in the end you are creating the resource GroupMember
    Otherwise we would create a GroupMember resource in the PendingMember resource. Do you know what I mean? I am not objecting your idea, but I am also not very sure which way to go.

  5. foFox commented on Jul 9, 2013

    @foFox
    Member

    But you are not really creating group member per say, as you do not have power to do so. A group member is an outcome of you creating invitation and invited person accepting it. That is my way of thinking about it. My intuition is that POST group/:id/members is not proper as you are not creating it. No one can go and actually make a group member. You must invite someone, and that person must accept invitation. There isn't a situation where you can actually just go ahead and create member. I think doing it that way is a bit confusing, where as just accepting membership, with PUT group/:id/invited?accepted=true is more clear. But that's just my idea.

  6. tsov commented on Jul 20, 2013

    @tsov
    ContributorAuthor
  7. tsov commented on Jul 24, 2013

    @tsov
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions