Skip to content
Extraits de code Groupes Projets
aspects_controller.rb 2,87 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
    
        @aspect = current_user.aspect_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
    
        @aspect  = current_user.aspect_by_id params[:id]
    
    Raphael's avatar
    Raphael a validé
        @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
    
      def public
        @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
                                          :scope=>MiniFB.scopes.join(","))
    
        @posts = current_user.visible_posts(:by_members_of => :all).paginate :page => params[:page], :per_page => 15, :order => 'created_at DESC'
    
        respond_with @aspect
      end
      
    
    maxwell's avatar
    maxwell a validé
        @remote_requests = Request.for_user(current_user).all
    
        @aspect = current_user.aspect_by_id(params[:id])
    
    
        data = clean_hash(params[:aspect])
        @aspect.update_attributes( data )
    
        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)
    
            flash[:error] = "Aspect editing failed for friend #{current_user.visible_person_by_id( move[:friend_id] ).real_name}."
            redirect_to aspects_manage_path
    
    Raphael's avatar
    Raphael a validé
        flash[:notice] = "Aspects edited successfully."
    
        redirect_to aspects_manage_path
    
        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
    
        if aspect = current_user.aspect_by_id(params[:to][:to])
    
          flash[:notice] = "You are now showing your friend a different aspect of yourself."
    
          render :nothing => true
    
          flash[:error] = "Invalid aspect id!"
          render aspects_manage_path
    
    
      private
      def clean_hash(params)
        return {
          :name => params[:name]
        }
      end