Commit b17a6a8f by liberodark

clean

parent b0aa2f10
SOURCE_URL=https://github.com/YunoHost-Apps/pia_ynh/releases/download/2.0.0/pia-back-community.tar.gz
SOURCE_SUM=e5210d1c3171b67f5bbc7919f2725c94c25c78464e7baba88541d70c5102bd7ed36dfac4f8d51d97e8132a58955044d63533ee094255d1088aef425acccb43b8
SOURCE_SUM_PRG=sha512sum
SOURCE_FORMAT=tar.gz
SOURCE_IN_SUBDIR=true
SOURCE_EXTRACT=true
SOURCE_FILENAME=pia-back.tar.gz
production:
adapter: postgresql
host: localhost
encoding: unicode
database: yunobase
pool: 5
username: yunouser
password: yunopass
template: template0
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
location __PATH__/ {
# Path to source
alias __FINALPATH__/ ;
# Force usage of https
if ($scheme = http) {
rewrite ^ https://$server_name$request_uri? permanent;
}
index index.html;
# Include SSOWAT user panel.
include conf.d/yunohost_panel.conf.inc;
}
location /pia-back/ {
# Path to source
alias /opt/pia-back/ ;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
class PiasController < ApplicationController
before_action :set_pia, only: %i[show update destroy duplicate]
before_action :set_serializer, only: %i[index show]
# GET /pias
def index
sorting = sorting_params
sorting = nil unless Pia.attribute_names.include?(sorting[:column])
sorting[:direction] = 'asc' if sorting && sorting[:direction] != 'desc'
@pias = Pia.all
@pias = @pias.order("#{sorting[:column]} #{sorting[:direction]}") if sorting.present?
render json: @pias, each_serializer: @index_serializer
end
# GET /pias/example
def example
pia = Pia.find_by(is_example: 1)
render json: pia, serializer: @index_serializer
end
# GET /pias/1
def show
render json: @pia, serializer: @index_serializer
end
# POST /pias
def create
pia_parameters = pia_params
#pia_parameters[:structure_data] = JSON.parse(pia_parameters[:structure_data]) if pia_parameters[:structure_data]
@pia = Pia.new(pia_parameters)
if @pia.save
render json: @pia, status: :created
else
render json: @pia.errors, status: :unprocessable_entity
end
end
# PATCH/PUT /pias/1
def update
pia_parameters = pia_params
#pia_parameters[:structure_data] = JSON.parse(pia_parameters[:structure_data]) if pia_parameters[:structure_data]
if @pia.update(pia_parameters)
render json: @pia
else
render json: @pia.errors, status: :unprocessable_entity
end
end
# DELETE /pias/1
def destroy
@pia.destroy
end
def duplicate
@clone = @pia.duplicate
render json: @clone
end
def import
@import_params = import_params
import_data_io = @import_params[:data]
json_str = import_data_io.read
Pia.import(json_str)
end
private
def import_params
params.fetch(:import, {}).permit(:data)
end
# Set seralizer for pias index
def set_serializer
@index_serializer = params[:export].present? ? ExportPiaSerializer : PiaSerializer
end
# Use callbacks to share common setup or constraints between actions.
def set_pia
@pia = Pia.find(params[:id])
end
# Only allow trusted sorting parameters
def sorting_params
params.fetch(:sort, {}).permit(:column, :direction)
end
# Only allow a trusted parameter "white list" through.
def pia_params
params.fetch(:pia, {}).permit(:status,
:name,
:author_name,
:evaluator_name,
:validator_name,
:dpo_status,
:dpo_opinion,
:dpos_names,
:people_names,
:concerned_people_opinion,
:concerned_people_status,
:concerned_people_searched_content,
:concerned_people_searched_opinion,
:rejection_reason,
:applied_adjustments,
:is_example,
:structure_id,
:structure_name,
:structure_sector_name,
:structure_data)
end
end
[Unit]
Description=Pia Backend
Requires=network.target
Requires=postgresql.service
[Service]
Type=simple
User=root
Group=users
WorkingDirectory=/opt/pia-back
Environment=RAILS_ENV=production
ExecStart=/bin/bash -c "/opt/pia-back/bin/rails s -b 127.0.0.1 -p 3000"
TimeoutSec=30
RestartSec=15s
Restart=always
[Install]
WantedBy=multi-user.target
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment