Remove "Import from pets" page
This hasn't worked for a while, and I don't know an API off the top of my head to drop in for it. Let's just delete it for now, and revisit it later if we want to!
This commit is contained in:
parent
e9034fb085
commit
c9dd0f7376
11 changed files with 0 additions and 194 deletions
|
@ -13,7 +13,6 @@
|
|||
@import closet_lists/form
|
||||
@import donations/show
|
||||
@import neopets_page_import_tasks/new
|
||||
@import neopets_users/form
|
||||
@import contributions/index
|
||||
@import items
|
||||
@import items/index
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
@import "../partials/secondary_nav"
|
||||
|
||||
body.neopets_users-new, body.neopets_users-create
|
||||
+secondary-nav
|
||||
|
||||
#neopets-user-form
|
||||
clear: both
|
||||
|
||||
label
|
||||
font-weight: bold
|
||||
margin-right: 1em
|
||||
|
||||
&:after
|
||||
content: ":"
|
||||
|
|
@ -1,34 +0,0 @@
|
|||
class NeopetsUsersController < ApplicationController
|
||||
before_action :authenticate_user!, :build_neopets_user
|
||||
|
||||
rescue_from NeopetsUser::NotFound, :with => :not_found
|
||||
|
||||
def new
|
||||
@neopets_user.username = current_user.contact_neopets_username
|
||||
end
|
||||
|
||||
def create
|
||||
@neopets_user.username = params[:neopets_user][:username]
|
||||
@neopets_user.list_id = params[:neopets_user][:list_id]
|
||||
@neopets_user.load!
|
||||
@neopets_user.save_hangers!
|
||||
|
||||
flash[:notice] = t('neopets_users.create.success',
|
||||
:user_name => @neopets_user.username,
|
||||
:count => @neopets_user.hangers.size)
|
||||
redirect_to user_closet_hangers_path(current_user)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def build_neopets_user
|
||||
@neopets_user = NeopetsUser.new current_user
|
||||
end
|
||||
|
||||
def not_found
|
||||
flash.now[:alert] = t('neopets_users.create.not_found',
|
||||
:user_name => @neopets_user.username)
|
||||
render :action => :new
|
||||
end
|
||||
end
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
require 'rocketamf/remote_gateway'
|
||||
require 'open-uri'
|
||||
|
||||
class NeopetsUser
|
||||
include ActiveModel::Conversion
|
||||
extend ActiveModel::Naming
|
||||
|
||||
NEOPETS_URL_ORIGIN = ENV['NEOPETS_URL_ORIGIN'] || 'https://www.neopets.com'
|
||||
GATEWAY_URL = NEOPETS_URL_ORIGIN + '/amfphp/gateway.php'
|
||||
GET_PETS_METHOD = RocketAMF::RemoteGateway.new(GATEWAY_URL).
|
||||
service('MobileService').action('getPets')
|
||||
|
||||
attr_accessor :username
|
||||
attr_reader :hangers, :list_id
|
||||
|
||||
def initialize(app_user)
|
||||
@app_user = app_user
|
||||
end
|
||||
|
||||
def list_id=(list_id)
|
||||
# TODO: use null lists instead
|
||||
@list_id = list_id
|
||||
if list_id == 'true'
|
||||
@closet_list = nil
|
||||
@hangers_owned = true
|
||||
elsif list_id == 'false'
|
||||
@closet_list = nil
|
||||
@hangers_owned = false
|
||||
elsif list_id.present?
|
||||
@closet_list = @app_user.closet_lists.find(list_id)
|
||||
@hangers_owned = @closet_list.hangers_owned?
|
||||
end
|
||||
end
|
||||
|
||||
def load!
|
||||
neopets_language_code = I18n.compatible_neopets_language_code_for(I18n.locale)
|
||||
begin
|
||||
envelope = GET_PETS_METHOD.request([@username]).post(
|
||||
:timeout => 4,
|
||||
:headers => {
|
||||
'Cookie' => "lang=#{neopets_language_code}"
|
||||
}
|
||||
)
|
||||
rescue RocketAMF::RemoteGateway::AMFError => e
|
||||
raise NotFound, e.message
|
||||
rescue RocketAMF::RemoteGateway::ConnectionError => e
|
||||
raise NotFound, e.message, e.backtrace
|
||||
end
|
||||
|
||||
|
||||
pets_data = envelope.messages[0].data.body
|
||||
raise NotFound if pets_data == false
|
||||
pets = pets_data.map { |pet| Pet.find_or_initialize_by(name: pet['name']) }
|
||||
items = pets.each(&:load!).map(&:items).flatten
|
||||
item_ids = items.map(&:id)
|
||||
item_quantities = {}
|
||||
items.each do |i|
|
||||
item_quantities[i] ||= 0
|
||||
item_quantities[i] += 1
|
||||
end
|
||||
|
||||
# TODO: DRY up with NeopetsPage
|
||||
# We don't want to insert duplicate hangers of what a user owns if they
|
||||
# already have it in another list (e.g. imports to Items You Own *after*
|
||||
# curating their Up For Trade list), so we check for the hanger's presence
|
||||
# in *all* items the user owns or wants (whichever is appropriate for this
|
||||
# request).
|
||||
hangers_scope = @app_user.closet_hangers.where(owned: @hangers_owned)
|
||||
existing_hanger_item_ids = hangers_scope.select(:item_id).
|
||||
where(item_id: item_ids).map(&:item_id)
|
||||
|
||||
@hangers = []
|
||||
item_quantities.each do |item, quantity|
|
||||
next if existing_hanger_item_ids.include?(item.id)
|
||||
hanger = hangers_scope.build
|
||||
hanger.item = item
|
||||
hanger.quantity = quantity
|
||||
hanger.list = @closet_list
|
||||
@hangers << hanger
|
||||
end
|
||||
end
|
||||
|
||||
def save_hangers!
|
||||
ClosetHanger.transaction { @hangers.each(&:save!) }
|
||||
end
|
||||
|
||||
def persisted?
|
||||
false
|
||||
end
|
||||
|
||||
class NotFound < RuntimeError; end
|
||||
end
|
||||
|
|
@ -53,7 +53,6 @@
|
|||
= link_to t('.import_from.closet'), new_neopets_page_import_task_path(page_type: 'closet', expected_index: 1)
|
||||
= link_to t('.import_from.safety_deposit'), new_neopets_page_import_task_path(page_type: 'safety_deposit', expected_index: 1)
|
||||
= link_to t('.import_from.gallery'), new_neopets_page_import_task_path(page_type: 'gallery', expected_index: 1)
|
||||
= link_to t('.import_from.neopets_user'), new_neopets_user_path
|
||||
= link_to t('.export_to.petpage'), petpage_user_closet_hangers_path(@user)
|
||||
|
||||
- unless public_perspective?
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
- title t('.title')
|
||||
- secondary_nav do
|
||||
= link_to t('.your_items_link'), user_closet_hangers_path(current_user), :class => 'button'
|
||||
|
||||
= form_for @neopets_user, :html => {:id => 'neopets-user-form'} do |f|
|
||||
%p= t '.explanation'
|
||||
|
||||
= f.label :username, t('.username_label')
|
||||
= f.text_field :username
|
||||
= f.select :list_id, neopets_page_list_options(current_user)
|
||||
= f.submit t('.submit')
|
||||
|
|
@ -95,7 +95,6 @@ en-MEEP:
|
|||
import_from:
|
||||
closet: Impeep from closet
|
||||
safety_deposit: Impeep from SDB
|
||||
neopets_user: Impeep from pets
|
||||
export_to:
|
||||
petpage: Expeep to petpage
|
||||
toggle_group:
|
||||
|
@ -417,15 +416,6 @@ en-MEEP:
|
|||
to Impress meepit list. I meep that it's all safe, but, if you're
|
||||
concerned, find a meepit and meep out the source code to be sure.
|
||||
|
||||
neopets_users:
|
||||
create:
|
||||
success:
|
||||
zero: Okay. We meeped %{user_name}'s pets, but already had these items
|
||||
meeped to your account.
|
||||
one: Success! We meeped %{user_name}'s pets, and meeped 1 item.
|
||||
other: Success! We meeped %{user_name}'s pets, and meeped %{count} items.
|
||||
not_found: Could not meep user %{user_name}. Is it meeped correctly?
|
||||
|
||||
new:
|
||||
title: Meemport from pets
|
||||
your_items_link: Back to Your Meeps
|
||||
|
|
|
@ -103,7 +103,6 @@ en:
|
|||
closet: Import from closet
|
||||
safety_deposit: Import from SDB
|
||||
gallery: Import from gallery
|
||||
neopets_user: Import from pets
|
||||
export_to:
|
||||
petpage: Export to petpage
|
||||
toggle_group:
|
||||
|
@ -477,15 +476,6 @@ en:
|
|||
concerned, find a programmer buddy and check out the source code to
|
||||
be sure.
|
||||
|
||||
neopets_users:
|
||||
create:
|
||||
success:
|
||||
zero: Okay. We loaded %{user_name}'s pets, but already had these items
|
||||
recorded to your account.
|
||||
one: Success! We loaded %{user_name}'s pets, and added 1 item.
|
||||
other: Success! We loaded %{user_name}'s pets, and added %{count} items.
|
||||
not_found: Could not find user %{user_name}. Is it spelled correctly?
|
||||
|
||||
new:
|
||||
title: Import from pets
|
||||
your_items_link: Back to Your Items
|
||||
|
|
|
@ -66,7 +66,6 @@ es:
|
|||
import_from:
|
||||
closet: Importar desde el ropero
|
||||
safety_deposit: Importar desde la Caja de Seguridad
|
||||
neopets_user: Importar desde pets
|
||||
export_to:
|
||||
petpage: Exportar para petpage
|
||||
toggle_group:
|
||||
|
@ -336,13 +335,6 @@ es:
|
|||
submit:
|
||||
header: ¡Envíalo!
|
||||
description: El código será analizado y obtendrá sólo la información de la cantidad de objetos y qué objetos hay en tu %{name}. Estos objetos los podrás añadir a tus listas de Dress to Impress. Este proceso es totalmente seguro pero si no te fías contacta con algún programador para que revise el código y estar seguro.
|
||||
neopets_users:
|
||||
create:
|
||||
success:
|
||||
zero: ¡Hemos cargado los pets de %{user_name}, pero ya tenías estos objetos guardados en tu cuenta!
|
||||
one: ¡Hecho! Hemos cargado los pets de %{user_name} y hemos añadido 1 objeto.
|
||||
other: ¡Hecho! Hemos cargado los pets de %{user_name} y hemos añadido %{count} objetos.
|
||||
not_found: No hemos podido encontrar a %{user_name}. ¿Lo has escrito bien?
|
||||
new:
|
||||
title: Importar de pets
|
||||
your_items_link: Volver a Tus Objetos
|
||||
|
|
|
@ -66,7 +66,6 @@ pt:
|
|||
import_from:
|
||||
closet: Importar do Armário
|
||||
safety_deposit: Importar do Cofre
|
||||
neopets_user: Importar dos Pets
|
||||
export_to:
|
||||
petpage: Exportar para Petpage
|
||||
toggle_group:
|
||||
|
@ -336,13 +335,6 @@ pt:
|
|||
submit:
|
||||
header: Enviar
|
||||
description: Vamos analisar o código que você nos enviou, agarre exclusivamente a identidade e quantidade de itens em seu %{name}, e acrescentar a sua lista de itens do Dress to Impress. Eu prometo que é tudo seguro, mas, se você estiver preocupado, encontre um amigo programador e verifique o código fonte para ter certeza.
|
||||
neopets_users:
|
||||
create:
|
||||
success:
|
||||
zero: Ok. Nós carregamos o pet de %{user_name}, mas já tínhamos esses itens registrados na sua conta.
|
||||
one: Sucesso! Nós carregamos o pet de %{user_name}, e adicionamos 1 item.
|
||||
other: Sucesso! Nós carregamos o pet de %{user_name} e adicionamos %{count} itens.
|
||||
not_found: Não encontramos o usuário %{user_name}. Está escrito corretamente?
|
||||
new:
|
||||
title: "Importar dos pets "
|
||||
your_items_link: Voltar para "Seus Items"
|
||||
|
|
|
@ -35,8 +35,6 @@ OpenneoImpressItems::Application.routes.draw do
|
|||
scope 'import' do
|
||||
resources :neopets_page_import_tasks, only: [:new, :create],
|
||||
path: ':page_type/pages/:expected_index'
|
||||
|
||||
resources :neopets_users, :only => [:new, :create], :path => 'neopets-users'
|
||||
end
|
||||
|
||||
get '/your-outfits', to: 'outfits#index', as: :current_user_outfits
|
||||
|
|
Loading…
Reference in a new issue