diff --git a/app/controllers/admin/features/education/application_controller.rb b/app/controllers/admin/features/education/application_controller.rb index 6f9adb9587f06b65daaef50bf7513e3c1bd1e6dc..1346e9b2b66c1581402e4937385f0369f506aa73 100644 --- a/app/controllers/admin/features/education/application_controller.rb +++ b/app/controllers/admin/features/education/application_controller.rb @@ -1,6 +1,6 @@ class Admin::Features::Education::ApplicationController < Admin::ApplicationController def breadcrumb super - add_breadcrumb I18n.t('features.education.title'), :admin_features_education_dashboard_path + add_breadcrumb Features::Education.model_name.human, :admin_features_education_dashboard_path end end diff --git a/app/controllers/admin/features/websites/application_controller.rb b/app/controllers/admin/features/websites/application_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..ad323abb97b07600fc781b25bb9829f10307d9e7 --- /dev/null +++ b/app/controllers/admin/features/websites/application_controller.rb @@ -0,0 +1,6 @@ +class Admin::Features::Websites::ApplicationController < Admin::ApplicationController + def breadcrumb + super + add_breadcrumb Features::Websites.model_name.human, :admin_features_websites_dashboard_path + end +end diff --git a/app/controllers/admin/features/websites/dashboard_controller.rb b/app/controllers/admin/features/websites/dashboard_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..88ada28a5ff94a0fc98e6075a52b26ab177d71f3 --- /dev/null +++ b/app/controllers/admin/features/websites/dashboard_controller.rb @@ -0,0 +1,5 @@ +class Admin::Features::Websites::DashboardController < Admin::Features::Websites::ApplicationController + def index + breadcrumb + end +end diff --git a/app/controllers/admin/features/websites/sites_controller.rb b/app/controllers/admin/features/websites/sites_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..d1d25e62bea013445182273c725cc7a8dde2048b --- /dev/null +++ b/app/controllers/admin/features/websites/sites_controller.rb @@ -0,0 +1,73 @@ +class Admin::Features::Websites::SitesController < Admin::Features::Websites::ApplicationController + load_and_authorize_resource class: Features::Websites::Site + + def index + @sites = current_university.features_websites_sites + breadcrumb + end + + def show + breadcrumb + end + + def new + breadcrumb + end + + def edit + breadcrumb + end + + def create + @site.university = current_university + respond_to do |format| + if @site.save + format.html { redirect_to [:admin, @site], notice: "Site was successfully created." } + format.json { render :show, status: :created, location: [:admin, @site] } + else + breadcrumb + format.html { render :new, status: :unprocessable_entity } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + def update + respond_to do |format| + if @site.update(site_params) + format.html { redirect_to [:admin, @site], notice: "Site was successfully updated." } + format.json { render :show, status: :ok, location: [:admin, @site] } + else + breadcrumb + format.html { render :edit, status: :unprocessable_entity } + format.json { render json: @site.errors, status: :unprocessable_entity } + end + end + end + + def destroy + @site.destroy + respond_to do |format| + format.html { redirect_to admin_features_websites_sites_url, notice: "Site was successfully destroyed." } + format.json { head :no_content } + end + end + + protected + + def breadcrumb + super + add_breadcrumb Features::Websites::Site.model_name.human(count: 2), admin_features_websites_sites_path + if @site + if @site.persisted? + add_breadcrumb @site, [:admin, @site] + else + add_breadcrumb 'Créer' + end + end + end + + def site_params + params.require(:features_websites_site).permit(:name, :domain) + end +end diff --git a/app/controllers/features/websites/sites_controller.rb b/app/controllers/features/websites/sites_controller.rb new file mode 100644 index 0000000000000000000000000000000000000000..9b40c2839b8509316d17a8e70a5dfb6b9e9fd9d1 --- /dev/null +++ b/app/controllers/features/websites/sites_controller.rb @@ -0,0 +1,11 @@ +class Features::Websites::SitesController < ApplicationController + def index + @sites = current_university.features_websites_sites + add_breadcrumb 'Sites', :features_websites_sites_path + end + + def show + @site = current_university.features_websites_sites.find(params[id]) + add_breadcrumb @site + end +end diff --git a/app/models/feature.rb b/app/models/feature.rb index 626d9e5a2b0b72d7cc4d5903ed78ea1c82d098b0..9ccc95d43ec52681e57f9a6a3165838704dba608 100644 --- a/app/models/feature.rb +++ b/app/models/feature.rb @@ -1,7 +1,8 @@ class Feature def self.all [ - :education + :education, + :websites ] end end diff --git a/app/models/features/education.rb b/app/models/features/education.rb index 2e057fd3ddd39d336c84ba1c025f3ca012db7b2c..9fa93d2be226d25ed51905131e295efb3e1ced24 100644 --- a/app/models/features/education.rb +++ b/app/models/features/education.rb @@ -1,5 +1,6 @@ module Features::Education extend ActiveModel::Naming + extend ActiveModel::Translation def self.table_name_prefix 'features_education_' diff --git a/app/models/features/education/qualiopi.rb b/app/models/features/education/qualiopi.rb index ebc7b4bf0659d1e257991b9e1fc26447d96cf322..9a4458c552e323ed0c025b45b21d8d27b18a2550 100644 --- a/app/models/features/education/qualiopi.rb +++ b/app/models/features/education/qualiopi.rb @@ -1,5 +1,6 @@ module Features::Education::Qualiopi extend ActiveModel::Naming + extend ActiveModel::Translation def self.table_name_prefix 'features_education_qualiopi_' diff --git a/app/models/features/websites.rb b/app/models/features/websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..9c3fd0289ae38ec618a92337565520c846158cf2 --- /dev/null +++ b/app/models/features/websites.rb @@ -0,0 +1,8 @@ +module Features::Websites + extend ActiveModel::Naming + extend ActiveModel::Translation + + def self.table_name_prefix + 'features_websites_' + end +end diff --git a/app/models/features/websites/site.rb b/app/models/features/websites/site.rb new file mode 100644 index 0000000000000000000000000000000000000000..dda275d71e94b3edb4637df0b6a62140fb8b2260 --- /dev/null +++ b/app/models/features/websites/site.rb @@ -0,0 +1,37 @@ +# == Schema Information +# +# Table name: features_websites_sites +# +# id :uuid not null, primary key +# domain :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null +# +# Indexes +# +# index_features_websites_sites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_... (university_id => universities.id) +# +class Features::Websites::Site < ApplicationRecord + belongs_to :university + + def domain_url + case Rails.env + when 'development' + "http://#{domain}.#{university.identifier}.osuny:3000" + when 'staging' + "https://#{domain}.#{university.identifier}.osuny.dev" + when 'production' + "https://#{domain}" + end + end + + def to_s + "#{name}" + end +end diff --git a/app/models/university.rb b/app/models/university.rb index ac6950cc3b64236572c4661bd07616e79158795e..80d480cd99eabdc0f5aee6a4a9208a16ab798298 100644 --- a/app/models/university.rb +++ b/app/models/university.rb @@ -19,7 +19,7 @@ class University < ApplicationRecord scope :ordered, -> { order(:name) } include WithIdentifier - include WithFeatureEducation + include WithFeatures def to_s "#{name}" diff --git a/app/models/university/with_feature_education.rb b/app/models/university/with_features.rb similarity index 55% rename from app/models/university/with_feature_education.rb rename to app/models/university/with_features.rb index 356809d49ac36c48101370dd8c701bf990ab6556..e42e78f442658803198e9783f14d99b5c96a029d 100644 --- a/app/models/university/with_feature_education.rb +++ b/app/models/university/with_features.rb @@ -1,7 +1,9 @@ -module University::WithFeatureEducation +module University::WithFeatures extend ActiveSupport::Concern included do + has_many :features_websites_sites, class_name: 'Features::Websites::Site', dependent: :destroy + has_many :features_education_programs, class_name: 'Features::Education::Program', dependent: :destroy end end diff --git a/app/views/admin/features/education/dashboard/index.html.erb b/app/views/admin/features/education/dashboard/index.html.erb index b8cf12aa84274a028b52713101e652d0731768e3..a8ca3d67c62b36c581613e07098f03c91c037d70 100644 --- a/app/views/admin/features/education/dashboard/index.html.erb +++ b/app/views/admin/features/education/dashboard/index.html.erb @@ -1 +1 @@ -<% content_for :title, t('features.education.title') %> +<% content_for :title, Features::Education.model_name.human %> diff --git a/app/views/admin/features/education/programs/index.json.jbuilder b/app/views/admin/features/education/programs/index.json.jbuilder index 518c5403daca9d23fb67a9e4c5fb58e3dfe56937..15edaff7d7a66bd4b8951e342e00ce661ad22b2c 100644 --- a/app/views/admin/features/education/programs/index.json.jbuilder +++ b/app/views/admin/features/education/programs/index.json.jbuilder @@ -1 +1 @@ -json.array! @programs, partial: "programs/program", as: :program +json.array! @programs, partial: "admin/features/education/programs/program", as: :program diff --git a/app/views/admin/features/websites/dashboard/index.html.erb b/app/views/admin/features/websites/dashboard/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..7754fb66b70173930968cd00c87cf0031550edb9 --- /dev/null +++ b/app/views/admin/features/websites/dashboard/index.html.erb @@ -0,0 +1 @@ +<% content_for :title, Features::Websites.model_name.human %> diff --git a/app/views/admin/features/websites/sites/_form.html.erb b/app/views/admin/features/websites/sites/_form.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..d1eab05e5f02a2d35994450a9493ee4664098da6 --- /dev/null +++ b/app/views/admin/features/websites/sites/_form.html.erb @@ -0,0 +1,13 @@ +<%= simple_form_for [:admin, @site] do |f| %> + <div class="row"> + <div class="col-md-6"> + <%= f.input :name %> + </div> + <div class="col-md-6"> + <%= f.input :domain %> + </div> + </div> + <% content_for :buttons do %> + <%= submit f %> + <% end %> +<% end %> diff --git a/app/views/admin/features/websites/sites/_site.json.jbuilder b/app/views/admin/features/websites/sites/_site.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..b66259e58818b52a86e235007959567c584c2664 --- /dev/null +++ b/app/views/admin/features/websites/sites/_site.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! features_websites_site, :id, :name, :domain, :created_at, :updated_at +json.url features_websites_site_url(features_websites_site, format: :json) diff --git a/app/views/admin/features/websites/sites/edit.html.erb b/app/views/admin/features/websites/sites/edit.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6af5485596f5a454933667f1a41e5f5cd9ba1dae --- /dev/null +++ b/app/views/admin/features/websites/sites/edit.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, @site %> + +<%= render 'form', site: @site %> diff --git a/app/views/admin/features/websites/sites/index.html.erb b/app/views/admin/features/websites/sites/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6982c94978b8d51eb896a5d084622977ad1067be --- /dev/null +++ b/app/views/admin/features/websites/sites/index.html.erb @@ -0,0 +1,27 @@ +<% content_for :title, Features::Websites::Site.model_name.human(count: 2) %> + +<table class="table"> + <thead> + <tr> + <th><%= Features::Websites::Site.human_attribute_name('name') %></th> + <th><%= Features::Websites::Site.human_attribute_name('domain') %></th> + <th></th> + </tr> + </thead> + <tbody> + <% @sites.each do |site| %> + <tr> + <td><%= link_to site, [:admin, site] %></td> + <td><%= site.domain %></td> + <td class="text-end"> + <%= edit_link site %> + <%= destroy_link site %> + </td> + </tr> + <% end %> + </tbody> +</table> + +<% content_for :buttons do %> + <%= create_link Features::Websites::Site %> +<% end %> diff --git a/app/views/admin/features/websites/sites/index.json.jbuilder b/app/views/admin/features/websites/sites/index.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..4eec47e61a8523bcb2c4496aae0c406021e180b5 --- /dev/null +++ b/app/views/admin/features/websites/sites/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @sites, partial: "admin/features/websites/sites/site", as: :site diff --git a/app/views/admin/features/websites/sites/new.html.erb b/app/views/admin/features/websites/sites/new.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..34e092077dad20d4d86226ba82da9bf83bf22738 --- /dev/null +++ b/app/views/admin/features/websites/sites/new.html.erb @@ -0,0 +1,3 @@ +<% content_for :title, Features::Websites::Site.model_name.human %> + +<%= render 'form', site: @site %> diff --git a/app/views/admin/features/websites/sites/show.html.erb b/app/views/admin/features/websites/sites/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..67c3fd78648a0307ca6dee5bfb7d53c622a55566 --- /dev/null +++ b/app/views/admin/features/websites/sites/show.html.erb @@ -0,0 +1,9 @@ +<% content_for :title, @site %> + +<p> + <%= link_to @site.domain_url, @site.domain_url, target: :_blank %> +</p> + +<% content_for :buttons do %> + <%= edit_link @site %> +<% end %> diff --git a/app/views/admin/features/websites/sites/show.json.jbuilder b/app/views/admin/features/websites/sites/show.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..4073c7237cdbb81ae86b1d01b2e92d97c7a5cfb6 --- /dev/null +++ b/app/views/admin/features/websites/sites/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "features_websites_sites/features_websites_site", features_websites_site: @features_websites_site diff --git a/app/views/features/education/programs/_program.json.jbuilder b/app/views/features/education/programs/_program.json.jbuilder index 7d57755126a6623d0af9d66daa8bf07c9719599a..ff41a9f2af841990205a041277dfddab521d690c 100644 --- a/app/views/features/education/programs/_program.json.jbuilder +++ b/app/views/features/education/programs/_program.json.jbuilder @@ -1,2 +1,2 @@ json.extract! program, :id, :university_id, :name, :level, :capacity, :ects, :continuing, :prerequisites, :objectives, :duration, :registration, :pedagogy, :evaluation, :accessibility, :created_at, :updated_at -json.url program_url(program, format: :json) +json.url features_education_program_url(program, format: :json) diff --git a/app/views/features/education/programs/index.html.erb b/app/views/features/education/programs/index.html.erb index 99b76e0d86d988c897a313f256c6858763c1afe7..4ce8c0e76128d8003e482e4e4060d3a5efc939b9 100644 --- a/app/views/features/education/programs/index.html.erb +++ b/app/views/features/education/programs/index.html.erb @@ -1,4 +1,5 @@ <%= content_for :title, Features::Education::Program.model_name.human(count: 2) %> + <h1><%= Features::Education::Program.model_name.human(count: 2) %></h1> <ul> diff --git a/app/views/features/education/programs/index.json.jbuilder b/app/views/features/education/programs/index.json.jbuilder index 518c5403daca9d23fb67a9e4c5fb58e3dfe56937..40e26f1fc94a40153d4d05873996596999a2c814 100644 --- a/app/views/features/education/programs/index.json.jbuilder +++ b/app/views/features/education/programs/index.json.jbuilder @@ -1 +1 @@ -json.array! @programs, partial: "programs/program", as: :program +json.array! @programs, partial: "features/education/programs/program", as: :program diff --git a/app/views/features/education/programs/show.json.jbuilder b/app/views/features/education/programs/show.json.jbuilder index 8053e7aed06e84c537d79ef7fae31ffaf8b13d08..0794afbe5d507af788f6725997a155b1a2980d0c 100644 --- a/app/views/features/education/programs/show.json.jbuilder +++ b/app/views/features/education/programs/show.json.jbuilder @@ -1 +1 @@ -json.partial! "programs/program", program: @program +json.partial! "features/education/programs/program", program: @program diff --git a/app/views/features/websites/sites/_site.json.jbuilder b/app/views/features/websites/sites/_site.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..8739db54925bf2aad299d7f6feb7df9179d33c2d --- /dev/null +++ b/app/views/features/websites/sites/_site.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! site, :id, :name, :domain, :created_at, :updated_at +json.url features_websites_site_url(features_websites_site, format: :json) diff --git a/app/views/features/websites/sites/index.html.erb b/app/views/features/websites/sites/index.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..845c56237c19e2a9dc7cf8969efefe7ef5c6ea10 --- /dev/null +++ b/app/views/features/websites/sites/index.html.erb @@ -0,0 +1,20 @@ +<%= content_for :title, Features::Websites::Site.model_name.human(count: 2) %> + +<h1><%= Features::Websites::Site.model_name.human(count: 2) %></h1> + +<table class="table"> + <thead> + <tr> + <th>Name</th> + <th>Domain</th> + </tr> + </thead> + <tbody> + <% @sites.each do |site| %> + <tr> + <td><%= site.name %></td> + <td><%= link_to site.domain_url, site.domain_url, target: :_blank %></td> + </tr> + <% end %> + </tbody> +</table> diff --git a/app/views/features/websites/sites/index.json.jbuilder b/app/views/features/websites/sites/index.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..a0f8a96f0223436dce7da83bb456ee2087fdce05 --- /dev/null +++ b/app/views/features/websites/sites/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @sites, partial: "features/websites/sites/site", as: :site diff --git a/app/views/features/websites/sites/show.html.erb b/app/views/features/websites/sites/show.html.erb new file mode 100644 index 0000000000000000000000000000000000000000..6723461de7c2a8ed5ff4ac567a1513bb1093cec8 --- /dev/null +++ b/app/views/features/websites/sites/show.html.erb @@ -0,0 +1,14 @@ +<p id="notice"><%= notice %></p> + +<p> + <strong>Name:</strong> + <%= @features_websites_site.name %> +</p> + +<p> + <strong>Domain:</strong> + <%= @features_websites_site.domain %> +</p> + +<%= link_to 'Edit', edit_features_websites_site_path(@features_websites_site) %> | +<%= link_to 'Back', features_websites_sites_path %> diff --git a/app/views/features/websites/sites/show.json.jbuilder b/app/views/features/websites/sites/show.json.jbuilder new file mode 100644 index 0000000000000000000000000000000000000000..d7da0c822b752a2dfd369b3cc7a53f6466931206 --- /dev/null +++ b/app/views/features/websites/sites/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "features/websites/sites/site", site: @site diff --git a/config/admin_navigation.rb b/config/admin_navigation.rb index 4ca3e4d36cd078ab39604a6271e19270b6c33d71..e10e0062c404380779209a756b9cb4899826583c 100644 --- a/config/admin_navigation.rb +++ b/config/admin_navigation.rb @@ -5,11 +5,15 @@ SimpleNavigation::Configuration.run do |navigation| navigation.items do |primary| primary.item :dashboard, t('dashboard'), admin_root_path, { icon: 'tachometer-alt' } primary.item :users, User.model_name.human(count: 2), admin_users_path, { icon: 'user' } - primary.item :education, I18n.t('features.education.title'), nil, { icon: 'graduation-cap' } do |secondary| + primary.item :education, Features::Education.model_name.human, nil, { icon: 'graduation-cap' } do |secondary| secondary.item :dashboard, t('dashboard'), admin_features_education_dashboard_path secondary.item :programs, Features::Education::Program.model_name.human(count: 2), admin_features_education_programs_path secondary.item :qualiopi, Features::Education::Qualiopi.model_name.human, admin_features_education_qualiopi_criterions_path end + primary.item :websites, Features::Websites.model_name.human, nil, { icon: 'sitemap' } do |secondary| + secondary.item :dashboard, t('dashboard'), admin_features_websites_dashboard_path + secondary.item :sites, Features::Websites::Site.model_name.human(count: 2), admin_features_websites_sites_path + end primary.item :settings, 'Paramètres', nil, { icon: 'cog' } end end diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml deleted file mode 100644 index 260e1c4ba6039a255c7858d049efd734a6200e4b..0000000000000000000000000000000000000000 --- a/config/locales/devise.en.yml +++ /dev/null @@ -1,65 +0,0 @@ -# Additional translations at https://github.com/heartcombo/devise/wiki/I18n - -en: - devise: - confirmations: - confirmed: "Your email address has been successfully confirmed." - send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." - send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." - failure: - already_authenticated: "You are already signed in." - inactive: "Your account is not activated yet." - invalid: "Invalid %{authentication_keys} or password." - locked: "Your account is locked." - last_attempt: "You have one more attempt before your account is locked." - not_found_in_database: "Invalid %{authentication_keys} or password." - timeout: "Your session expired. Please sign in again to continue." - unauthenticated: "You need to sign in or sign up before continuing." - unconfirmed: "You have to confirm your email address before continuing." - mailer: - confirmation_instructions: - subject: "Confirmation instructions" - reset_password_instructions: - subject: "Reset password instructions" - unlock_instructions: - subject: "Unlock instructions" - email_changed: - subject: "Email Changed" - password_change: - subject: "Password Changed" - omniauth_callbacks: - failure: "Could not authenticate you from %{kind} because \"%{reason}\"." - success: "Successfully authenticated from %{kind} account." - passwords: - no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." - send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." - send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." - updated: "Your password has been changed successfully. You are now signed in." - updated_not_active: "Your password has been changed successfully." - registrations: - destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." - signed_up: "Welcome! You have signed up successfully." - signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." - signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." - signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." - update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." - updated: "Your account has been updated successfully." - updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again." - sessions: - signed_in: "Signed in successfully." - signed_out: "Signed out successfully." - already_signed_out: "Signed out successfully." - unlocks: - send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." - send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." - unlocked: "Your account has been unlocked successfully. Please sign in to continue." - errors: - messages: - already_confirmed: "was already confirmed, please try signing in" - confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" - expired: "has expired, please request a new one" - not_found: "not found" - not_locked: "was not locked" - not_saved: - one: "1 error prohibited this %{resource} from being saved:" - other: "%{count} errors prohibited this %{resource} from being saved:" diff --git a/config/locales/en.yml b/config/locales/en.yml deleted file mode 100644 index cf9b342d0aebfa248437d33d7a720b1a1116608a..0000000000000000000000000000000000000000 --- a/config/locales/en.yml +++ /dev/null @@ -1,33 +0,0 @@ -# Files in the config/locales directory are used for internationalization -# and are automatically loaded by Rails. If you want to use locales other -# than English, add the necessary files in this directory. -# -# To use the locales, use `I18n.t`: -# -# I18n.t 'hello' -# -# In views, this is aliased to just `t`: -# -# <%= t('hello') %> -# -# To use a different locale, set it with `I18n.locale`: -# -# I18n.locale = :es -# -# This would use the information in config/locales/es.yml. -# -# The following keys must be escaped otherwise they will not be retrieved by -# the default I18n backend: -# -# true, false, on, off, yes, no -# -# Instead, surround them with single quotes. -# -# en: -# 'true': 'foo' -# -# To learn more, please read the Rails Internationalization guide -# available at https://guides.rubyonrails.org/i18n.html. - -en: - hello: "Hello world" diff --git a/config/locales/features/education/fr.yml b/config/locales/features/education/fr.yml index dc43f37b892bb761ac0bb49d94999564f7bb9aab..b04bf2defead62e596860635b873f7d5498b1c04 100644 --- a/config/locales/features/education/fr.yml +++ b/config/locales/features/education/fr.yml @@ -1,16 +1,13 @@ fr: - features: - education: - title: Education - qualiopi: Qualiopi + activemodel: + models: + features/education: Éducation + features/education/qualiopi: Qualiopi activerecord: models: features/education/program: one: Formation other: Formations - features/education/qualiopi: - one: Qualiopi - other: Qualiopi features/education/qualiopi/criterion: one: Critère other: Critères diff --git a/config/locales/features/websites/fr.yml b/config/locales/features/websites/fr.yml new file mode 100644 index 0000000000000000000000000000000000000000..fcc5f43fd2f704e49e64a4a09507a4846244c02c --- /dev/null +++ b/config/locales/features/websites/fr.yml @@ -0,0 +1,13 @@ +fr: + activemodel: + models: + features/websites: Sites Web + activerecord: + models: + features/websites/site: + one: Site + other: Sites + attributes: + features/websites/site: + name: Nom + domain: Domaine diff --git a/config/locales/simple_form.en.yml b/config/locales/simple_form.en.yml deleted file mode 100644 index 23743833423490f1c57b8f6b3e24620b6b3a8035..0000000000000000000000000000000000000000 --- a/config/locales/simple_form.en.yml +++ /dev/null @@ -1,31 +0,0 @@ -en: - simple_form: - "yes": 'Yes' - "no": 'No' - required: - text: 'required' - mark: '*' - # You can uncomment the line below if you need to overwrite the whole required html. - # When using html, text and mark won't be used. - # html: '<abbr title="required">*</abbr>' - error_notification: - default_message: "Please review the problems below:" - # Examples - # labels: - # defaults: - # password: 'Password' - # user: - # new: - # email: 'E-mail to sign in.' - # edit: - # email: 'E-mail.' - # hints: - # defaults: - # username: 'User name to sign in.' - # password: 'No special characters, please.' - # include_blanks: - # defaults: - # age: 'Rather not say' - # prompts: - # defaults: - # age: 'Select your age' diff --git a/config/routes/admin/features/websites.rb b/config/routes/admin/features/websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..9d10b6a89be6232ec80e87dfaf3bacf15204a0bd --- /dev/null +++ b/config/routes/admin/features/websites.rb @@ -0,0 +1,4 @@ +namespace :websites do + resources :sites + get 'dashboard' => 'dashboard#index', as: :dashboard +end diff --git a/config/routes/features/websites.rb b/config/routes/features/websites.rb new file mode 100644 index 0000000000000000000000000000000000000000..361c6c8e90fa15d92616925c21185d478013a399 --- /dev/null +++ b/config/routes/features/websites.rb @@ -0,0 +1,4 @@ +namespace :websites do + resources :sites + root to: 'sites#index' +end diff --git a/db/migrate/20210811102819_create_features_websites_sites.rb b/db/migrate/20210811102819_create_features_websites_sites.rb new file mode 100644 index 0000000000000000000000000000000000000000..ed15ef95d4e637a7c98f4b6e24355b5a69dca979 --- /dev/null +++ b/db/migrate/20210811102819_create_features_websites_sites.rb @@ -0,0 +1,11 @@ +class CreateFeaturesWebsitesSites < ActiveRecord::Migration[6.1] + def change + create_table :features_websites_sites, id: :uuid do |t| + t.references :university, null: false, foreign_key: true, type: :uuid + t.string :name + t.string :domain + + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index cc201452bbe5bc05169a791b32e01c80bb7654e0..631bea021b6a03871339e6fc0c6f764ba6fd0030 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2021_08_11_082802) do +ActiveRecord::Schema.define(version: 2021_08_11_102819) do # These are extensions that must be enabled in order to support this database enable_extension "pgcrypto" @@ -58,6 +58,15 @@ ActiveRecord::Schema.define(version: 2021_08_11_082802) do t.index ["criterion_id"], name: "index_features_education_qualiopi_indicators_on_criterion_id" end + create_table "features_websites_sites", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| + t.uuid "university_id", null: false + t.string "name" + t.string "domain" + t.datetime "created_at", precision: 6, null: false + t.datetime "updated_at", precision: 6, null: false + t.index ["university_id"], name: "index_features_websites_sites_on_university_id" + end + create_table "universities", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t| t.bigint "integer_id" t.string "name" @@ -103,4 +112,5 @@ ActiveRecord::Schema.define(version: 2021_08_11_082802) do add_foreign_key "features_education_programs", "universities" add_foreign_key "features_education_qualiopi_indicators", "features_education_qualiopi_criterions", column: "criterion_id" + add_foreign_key "features_websites_sites", "universities" end diff --git a/test/controllers/features/websites/sites_controller_test.rb b/test/controllers/features/websites/sites_controller_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..797402be1f02cdb7c16d82b65eac0e4b02f1fc3c --- /dev/null +++ b/test/controllers/features/websites/sites_controller_test.rb @@ -0,0 +1,48 @@ +require "test_helper" + +class Features::Websites::SitesControllerTest < ActionDispatch::IntegrationTest + setup do + @features_websites_site = features_websites_sites(:one) + end + + test "should get index" do + get features_websites_sites_url + assert_response :success + end + + test "should get new" do + get new_features_websites_site_url + assert_response :success + end + + test "should create features_websites_site" do + assert_difference('Features::Websites::Site.count') do + post features_websites_sites_url, params: { features_websites_site: { domain: @features_websites_site.domain, name: @features_websites_site.name } } + end + + assert_redirected_to features_websites_site_url(Features::Websites::Site.last) + end + + test "should show features_websites_site" do + get features_websites_site_url(@features_websites_site) + assert_response :success + end + + test "should get edit" do + get edit_features_websites_site_url(@features_websites_site) + assert_response :success + end + + test "should update features_websites_site" do + patch features_websites_site_url(@features_websites_site), params: { features_websites_site: { domain: @features_websites_site.domain, name: @features_websites_site.name } } + assert_redirected_to features_websites_site_url(@features_websites_site) + end + + test "should destroy features_websites_site" do + assert_difference('Features::Websites::Site.count', -1) do + delete features_websites_site_url(@features_websites_site) + end + + assert_redirected_to features_websites_sites_url + end +end diff --git a/test/fixtures/features/websites/sites.yml b/test/fixtures/features/websites/sites.yml new file mode 100644 index 0000000000000000000000000000000000000000..5883646f214a9d4baf0e15bdbaffacd9d66ad15c --- /dev/null +++ b/test/fixtures/features/websites/sites.yml @@ -0,0 +1,27 @@ +# == Schema Information +# +# Table name: features_websites_sites +# +# id :uuid not null, primary key +# domain :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null +# +# Indexes +# +# index_features_websites_sites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_... (university_id => universities.id) +# + +one: + name: MyString + domain: MyString + +two: + name: MyString + domain: MyString diff --git a/test/models/features/websites/site_test.rb b/test/models/features/websites/site_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..b3d51844fbb257babb9f87661193a6807b5ddf32 --- /dev/null +++ b/test/models/features/websites/site_test.rb @@ -0,0 +1,26 @@ +# == Schema Information +# +# Table name: features_websites_sites +# +# id :uuid not null, primary key +# domain :string +# name :string +# created_at :datetime not null +# updated_at :datetime not null +# university_id :uuid not null +# +# Indexes +# +# index_features_websites_sites_on_university_id (university_id) +# +# Foreign Keys +# +# fk_rails_... (university_id => universities.id) +# +require "test_helper" + +class Features::Websites::SiteTest < ActiveSupport::TestCase + # test "the truth" do + # assert true + # end +end diff --git a/test/system/features/websites/sites_test.rb b/test/system/features/websites/sites_test.rb new file mode 100644 index 0000000000000000000000000000000000000000..b6e665bad81430226382a7aec8ff8324beb25f1a --- /dev/null +++ b/test/system/features/websites/sites_test.rb @@ -0,0 +1,45 @@ +require "application_system_test_case" + +class Features::Websites::SitesTest < ApplicationSystemTestCase + setup do + @features_websites_site = features_websites_sites(:one) + end + + test "visiting the index" do + visit features_websites_sites_url + assert_selector "h1", text: "Features/Websites/Sites" + end + + test "creating a Site" do + visit features_websites_sites_url + click_on "New Features/Websites/Site" + + fill_in "Domain", with: @features_websites_site.domain + fill_in "Name", with: @features_websites_site.name + click_on "Create Site" + + assert_text "Site was successfully created" + click_on "Back" + end + + test "updating a Site" do + visit features_websites_sites_url + click_on "Edit", match: :first + + fill_in "Domain", with: @features_websites_site.domain + fill_in "Name", with: @features_websites_site.name + click_on "Update Site" + + assert_text "Site was successfully updated" + click_on "Back" + end + + test "destroying a Site" do + visit features_websites_sites_url + page.accept_confirm do + click_on "Destroy", match: :first + end + + assert_text "Site was successfully destroyed" + end +end