forked from diaspora/diaspora
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
you can now follow / unfollow a post from the stream; fixed cukes.
- Loading branch information
1 parent
b27961b
commit 32f93a0
Showing
21 changed files
with
329 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Copyright (c) 2010-2011, Diaspora Inc. This file is | ||
# licensed under the Affero General Public License version 3 or later. See | ||
# the COPYRIGHT file. | ||
|
||
class ParticipationsController < ApplicationController | ||
include ApplicationHelper | ||
before_filter :authenticate_user! | ||
|
||
respond_to :mobile, | ||
:json | ||
|
||
def create | ||
@participation = current_user.participate!(target) if target | ||
|
||
if @participation | ||
respond_to do |format| | ||
format.mobile { redirect_to post_path(@participation.post_id) } | ||
format.json { render :json => @participation.parent.as_api_response(:backbone), :status => 201 } | ||
end | ||
else | ||
render :nothing => true, :status => 422 | ||
end | ||
end | ||
|
||
def destroy | ||
@participation = Participation.where(:id => params[:id], :author_id => current_user.person.id).first | ||
|
||
if @participation | ||
current_user.retract(@participation) | ||
respond_to do |format| | ||
format.any { } | ||
format.json{ render :json => @participation.parent.as_api_response(:backbone), :status => 202 } | ||
end | ||
else | ||
respond_to do |format| | ||
format.mobile { redirect_to :back } | ||
format.json { render :nothing => true, :status => 403} | ||
end | ||
end | ||
end | ||
|
||
def index | ||
if target | ||
@participations = target.participations.includes(:author => :profile) | ||
@people = @participations.map(&:author) | ||
|
||
respond_to do |format| | ||
format.all{ render :layout => false } | ||
format.json{ render :json => @participations.as_api_response(:backbone) } | ||
end | ||
else | ||
render :nothing => true, :status => 404 | ||
end | ||
end | ||
|
||
protected | ||
|
||
def target | ||
@target ||= if params[:post_id] | ||
current_user.find_visible_shareable_by_id(Post, params[:post_id]) | ||
else | ||
comment = Comment.find(params[:comment_id]) | ||
comment = nil unless current_user.find_visible_shareable_by_id(Post, comment.commentable_id) | ||
comment | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
app.collections.Participations = Backbone.Collection.extend({ | ||
model: app.models.Participation, | ||
|
||
initialize : function(models, options) { | ||
this.url = "/posts/" + options.post.id + "/participations" //not delegating to post.url() because when it is in a stream collection it delegates to that url | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
app.models.Participation = Backbone.Model.extend({ }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.