Skip to content
Extraits de code Groupes Projets
aspects_controller.rb 2,45 ko
Newer Older
  • Learn to ignore specific revisions
  • Raphael's avatar
    Raphael a validé
    #   Copyright (c) 2010, Diaspora Inc.  This file is
    
    Raphael's avatar
    Raphael a validé
    #   licensed under the Affero General Public License version 3.  See
    #   the COPYRIGHT file.
    
    Raphael's avatar
    Raphael a validé
    class AspectsController < ApplicationController
    
      before_filter :authenticate_user!
    
    
        @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
    
    Raphael's avatar
    Raphael a validé
        @aspect = :all
    
    Raphael's avatar
    Raphael a validé
        @aspect = current_user.aspect params[:aspect]
    
        flash[:notice] = I18n.t('aspects.create.success')
    
        respond_with :location => aspects_manage_path
    
    Raphael's avatar
    Raphael a validé
        @aspect = Aspect.new
    
    Raphael's avatar
    Raphael a validé
        @aspect = Aspect.find_by_id params[:id]
    
    danielvincent's avatar
    danielvincent a validé
    
        begin
          current_user.drop_aspect @aspect
          flash[:notice] = "#{@aspect.name} was successfully removed."
        rescue RuntimeError => e 
          flash[:error] = e.message
        end
    
        respond_with :location => aspects_manage_path
    
    Raphael's avatar
    Raphael a validé
        @aspect   = Aspect.find_by_id params[:id]
        @friends = @aspect.people
        @posts   = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
    
    Raphael's avatar
    Raphael a validé
        respond_with @aspect
    
    maxwell's avatar
    maxwell a validé
        @remote_requests = Request.for_user(current_user).all
    
    Raphael's avatar
    Raphael a validé
        @aspect = Aspect.find_by_id(params[:id])
        @aspect.update_attributes(params[:aspect])
    
        flash[:notice] = "Your aspect, #{@aspect.name}, has been successfully edited."
        respond_with @aspect
    
    Raphael's avatar
    Raphael a validé
      def move_friends
        params[:moves].each{ |move|
          move = move[1]
          unless current_user.move_friend(move)
    
    Raphael's avatar
    Raphael a validé
            flash[:error] = "Aspect editing failed for friend #{Person.find_by_id( move[:friend_id] ).real_name}."
            redirect_to Aspect.first, :action => "edit"
    
    Raphael's avatar
    Raphael a validé
        flash[:notice] = "Aspects edited successfully."
        redirect_to Aspect.first, :action => "edit"
    
        unless current_user.move_friend( :friend_id => params[:friend_id], :from => params[:from], :to => params[:to][:to])
    
          flash[:error] = "didn't work #{params.inspect}"
        end
    
    Raphael's avatar
    Raphael a validé
        if aspect = Aspect.first(:id => params[:to][:to])
    
          flash[:notice] = "You are now showing your friend a different aspect of yourself."
          respond_with aspect
    
          flash[:notice] = "You are now showing your friend a different aspect of yourself."
          respond_with Person.first(:id => params[:friend_id])