2019-03-26 15:32:20 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-07-03 23:25:23 +00:00
|
|
|
# Política de acceso para sitios
|
|
|
|
class SitePolicy
|
|
|
|
attr_reader :site, :usuarie
|
|
|
|
|
|
|
|
def initialize(usuarie, site)
|
|
|
|
@usuarie = usuarie
|
2018-09-28 15:27:25 +00:00
|
|
|
@site = site
|
|
|
|
end
|
|
|
|
|
2019-07-04 00:47:59 +00:00
|
|
|
# Todes les usuaries pueden ver sus propios sitios
|
2018-09-28 15:27:25 +00:00
|
|
|
def index?
|
2019-07-03 23:25:23 +00:00
|
|
|
true
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
|
2019-07-10 19:58:06 +00:00
|
|
|
# Todes les usuaries pueden ver el sitio si aceptaron la invitación
|
2018-09-28 15:27:25 +00:00
|
|
|
def show?
|
2019-07-10 19:58:06 +00:00
|
|
|
!@usuarie.rol_for_site(@site).temporal
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
|
2019-07-10 19:58:06 +00:00
|
|
|
# Les invitades no pueden generar el sitio y les usuaries solo hasta
|
|
|
|
# que aceptan la invitación
|
2018-09-28 15:27:25 +00:00
|
|
|
def build?
|
2019-07-10 19:58:06 +00:00
|
|
|
show? && !site.invitade?(usuarie)
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def send_public_file?
|
|
|
|
true
|
|
|
|
end
|
|
|
|
|
|
|
|
def enqueue?
|
2019-07-04 00:47:59 +00:00
|
|
|
build?
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def build_log?
|
2019-07-04 00:47:59 +00:00
|
|
|
build?
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def reorder_posts?
|
2019-07-04 00:47:59 +00:00
|
|
|
build?
|
2018-09-28 15:27:25 +00:00
|
|
|
end
|
|
|
|
end
|