Commit 960e6517 authored by tamatsyk's avatar tamatsyk Committed by Steffen van Bergerem
Browse files

internationalize controller rescue_from text

Fix typos

change forbitten to forbidden

fix styling issue and copypaste

improve code style for aspec_memberships_controller.rb with rubocop

fix styling issues

aligned elements of hash literals

fix typo

fix locale name and styling of its usage

fix failing tests

closes #6554
parent e3001998
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
# 0.5.7.0

## Refactor
* Internationalize controller rescue\_from text [#6554](https://github.com/diaspora/diaspora/pull/6554)

# Bug fixes
Fix plural rules handling more than wanted as "one" [#6630](https://github.com/diaspora/diaspora/pull/6630)

+16 −17
Original line number Diff line number Diff line
@@ -9,15 +9,15 @@ class AspectMembershipsController < ApplicationController
  respond_to :html, :json

  def destroy
    aspect = current_user.aspects.joins(:aspect_memberships).where(:aspect_memberships=>{:id=>params[:id]}).first
    contact = current_user.contacts.joins(:aspect_memberships).where(:aspect_memberships=>{:id=>params[:id]}).first
    aspect = current_user.aspects.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first
    contact = current_user.contacts.joins(:aspect_memberships).where(aspect_memberships: {id: params[:id]}).first

    raise ActiveRecord::RecordNotFound unless aspect.present? && contact.present?

    raise Diaspora::NotMine unless current_user.mine?(aspect) &&
                                   current_user.mine?(contact)

    membership = contact.aspect_memberships.where(:aspect_id => aspect.id).first
    membership = contact.aspect_memberships.where(aspect_id: aspect.id).first

    raise ActiveRecord::RecordNotFound unless membership.present?

@@ -26,17 +26,17 @@ class AspectMembershipsController < ApplicationController

    # set the flash message
    if success
      flash.now[:notice] = I18n.t 'aspect_memberships.destroy.success'
      flash.now[:notice] = I18n.t "aspect_memberships.destroy.success"
    else
      flash.now[:error] = I18n.t 'aspect_memberships.destroy.failure'
      flash.now[:error] = I18n.t "aspect_memberships.destroy.failure"
    end

    respond_to do |format|
      format.json do
        if success
          render :json => AspectMembershipPresenter.new(membership).base_hash
          render json: AspectMembershipPresenter.new(membership).base_hash
        else
          render :text => membership.errors.full_messages, :status => 403
          render text: membership.errors.full_messages, status: 403
        end
      end

@@ -46,37 +46,36 @@ class AspectMembershipsController < ApplicationController

  def create
    @person = Person.find(params[:person_id])
    @aspect = current_user.aspects.where(:id => params[:aspect_id]).first
    @aspect = current_user.aspects.where(id: params[:aspect_id]).first

    @contact = current_user.share_with(@person, @aspect)

    if @contact.present?
      flash.now[:notice] =  I18n.t('aspects.add_to_aspect.success')
      flash.now[:notice] = I18n.t("aspects.add_to_aspect.success")
      respond_with do |format|
        format.json do
          render :json => AspectMembershipPresenter.new(
            AspectMembership.where(:contact_id => @contact.id, :aspect_id => @aspect.id).first)
          render json: AspectMembershipPresenter.new(
            AspectMembership.where(contact_id: @contact.id, aspect_id: @aspect.id).first)
          .base_hash
        end

        format.all { redirect_to :back }
      end
    else
      flash.now[:error] = I18n.t('contacts.create.failure')
      render :nothing => true, :status => 409
      flash.now[:error] = I18n.t("contacts.create.failure")
      render nothing: true, status: 409
    end
  end

  rescue_from ActiveRecord::StatementInvalid do
    render :text => "Duplicate record rejected.", :status => 400
    render text: I18n.t("aspect_memberships.destroy.invalid_statement"), status: 400
  end

  rescue_from ActiveRecord::RecordNotFound do
    render :text => I18n.t('aspect_memberships.destroy.no_membership'), :status => 404
    render text: I18n.t("aspect_memberships.destroy.no_membership"), status: 404
  end

  rescue_from Diaspora::NotMine do
    render :text => "You are not allowed to do that.", :status => 403
    render text: I18n.t("aspect_memberships.destroy.forbidden"), status: 403
  end

end
+1 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ class InvitationCodesController < ApplicationController
  before_action :ensure_valid_invite_code

  rescue_from ActiveRecord::RecordNotFound do
    redirect_to root_url, :notice => "That invite code is no longer valid"
    redirect_to root_url, :notice => I18n.t('invitation_codes.not_valid')
  end

  def show 
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ class PostsController < ApplicationController
  end

  rescue_from Diaspora::NotMine do
    render text: "You are not allowed to do that", status: 403
    render text: I18n.t("posts.show.forbidden"), status: 403
  end

  def show
+5 −0
Original line number Diff line number Diff line
@@ -275,6 +275,8 @@ en:
      success: "Successfully removed person from aspect."
      failure: "Failed to remove person from aspect."
      no_membership: "Could not find the selected person in that aspect."
      forbidden: "You are not allowed to do that."
      invalid_statement: "Duplicate record rejected."

  bookmarklet:
    heading: "Bookmarklet"
@@ -582,6 +584,8 @@ en:

  invitation_codes:
    excited: "%{name} is excited to see you here."
    not_valid: "That invite code is no longer valid"
    
  invitations:
    create:
      sent: "Invitations have been sent to: %{emails}"
@@ -967,6 +971,7 @@ en:
      destroy: "Delete"
      permalink: "Permalink"
      not_found: "Sorry, we couldn’t find that post."
      forbidden: "You are not allowed to do that"
      photos_by:
        zero: "No photos by %{author}"
        one: "One photo by %{author}"
Loading