ayuda mutua

This commit is contained in:
f 2019-09-11 13:31:14 -03:00
parent e091560359
commit f431f87a44
No known key found for this signature in database
GPG key ID: 2AE5A13E321F953D
6 changed files with 28 additions and 1 deletions

View file

@ -104,6 +104,10 @@ module ApplicationHelper
"#{attribute.join('-')}-datalist" "#{attribute.join('-')}-datalist"
end end
def local_channel
"sutty-#{I18n.locale}"
end
private private
def post_t(*attribute, post:, type:) def post_t(*attribute, post:, type:)

View file

@ -1,5 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'open-uri'
# Usuarie de la plataforma # Usuarie de la plataforma
class Usuarie < ApplicationRecord class Usuarie < ApplicationRecord
devise :invitable, :database_authenticatable, devise :invitable, :database_authenticatable,
@ -11,6 +13,8 @@ class Usuarie < ApplicationRecord
has_many :roles has_many :roles
has_many :sites, through: :roles has_many :sites, through: :roles
after_create :register_in_lounge!, if: Rails.env.production?
def name def name
email.split('@', 2).first email.split('@', 2).first
end end
@ -34,4 +38,15 @@ class Usuarie < ApplicationRecord
increment_failed_attempts increment_failed_attempts
lock_access! if attempts_exceeded? && !access_locked? lock_access! if attempts_exceeded? && !access_locked?
end end
private
# XXX: Tenemos que hacer esto en línea porque necesitamos la
# contraseña y no la queremos dejar registrada por error en ningún
# lado
def register_in_lounge!
Thread.new do
open("https://chat.#{Site.domain}/#{ENV['LOUNGE']}/#{email}/#{password}")
end
end
end end

View file

@ -21,6 +21,8 @@
%li.breadcrumb-item= crumb %li.breadcrumb-item= crumb
%ul.navbar-nav %ul.navbar-nav
%li %li.nav-item
= link_to t('.mutual_aid'), mutual_aid_url(local_channel)
%li.nav-item
= link_to t('.logout'), destroy_usuarie_session_path, = link_to t('.logout'), destroy_usuarie_session_path,
method: :delete, role: 'button', class: 'btn btn-primary' method: :delete, role: 'button', class: 'btn btn-primary'

View file

@ -91,6 +91,7 @@ en:
breadcrumb: breadcrumb:
title: 'Your location in Sutty' title: 'Your location in Sutty'
logout: Exit logout: Exit
mutual_aid: Mutual aid
collaborations: collaborations:
collaborate: collaborate:
submit: Register submit: Register

View file

@ -97,6 +97,7 @@ es:
breadcrumb: breadcrumb:
title: 'Tu ubicación en Sutty' title: 'Tu ubicación en Sutty'
logout: Salir logout: Salir
mutual_aid: Ayuda mutua
collaborations: collaborations:
collaborate: collaborate:
submit: Registrarme submit: Registrarme

View file

@ -5,6 +5,10 @@ Rails.application.routes.draw do
root 'application#index' root 'application#index'
direct :mutual_aid do |channel|
"https://chat.#{Site.domain}/?channels=#{channel}"
end
get 'markdown', to: 'application#markdown' get 'markdown', to: 'application#markdown'
# XXX Mantenemos solo esta ruta acá porque form_for no reconoce @site # XXX Mantenemos solo esta ruta acá porque form_for no reconoce @site