diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000000..325bfc036d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,51 @@ +# See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files. + +# Ignore git directory. +/.git/ +/.gitignore + +# Ignore bundler config. +/.bundle + +# Ignore all environment files. +/.env* + +# Ignore all default key files. +/config/master.key +/config/credentials/*.key + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/.keep + +# Ignore assets. +/node_modules/ +/app/assets/builds/* +!/app/assets/builds/.keep +/public/assets + +# Ignore CI service files. +/.github + +# Ignore Kamal files. +/config/deploy*.yml +/.kamal + +# Ignore development files +/.devcontainer + +# Ignore Docker-related files +/.dockerignore +/Dockerfile* diff --git a/.env.example b/.env.example new file mode 100644 index 0000000000..8463db78b3 --- /dev/null +++ b/.env.example @@ -0,0 +1,30 @@ +# ============================================ +# CAMAAR - Email Configuration +# ============================================ +# Copy this file to .env and fill in the values: +# cp .env.example .env +# +# GMAIL SETUP (Recommended): +# 1. Enable 2-Step Verification on your Google account: +# https://myaccount.google.com/security +# 2. Generate an App Password: +# https://myaccount.google.com/apppasswords +# 3. Use that App Password below (NOT your regular Gmail password) +# +# For other providers, change SMTP_ADDRESS, SMTP_PORT, SMTP_DOMAIN accordingly. +# ============================================ + +# Sender email address (shown as "From" in sent emails) +MAILER_FROM_ADDRESS=camaar@gmail.com + +# SMTP Configuration (Gmail defaults shown) +SMTP_ADDRESS=smtp.gmail.com +SMTP_PORT=587 +SMTP_USERNAME=your_email@gmail.com +SMTP_PASSWORD=your_16_digit_app_password +SMTP_DOMAIN=gmail.com + +# Application URL (used in email links for production) +# In development, this defaults to http://localhost:3000 +APP_HOST=localhost:3000 +APP_PROTOCOL=http \ No newline at end of file diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..8dc4323435 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,9 @@ +# See https://git-scm.com/docs/gitattributes for more about git attribute files. + +# Mark the database schema as having been generated. +db/schema.rb linguist-generated + +# Mark any vendored files as having been vendored. +vendor/* linguist-vendored +config/credentials/*.yml.enc diff=rails_credentials +config/credentials.yml.enc diff=rails_credentials diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000000..83610cfa4c --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,12 @@ +version: 2 +updates: +- package-ecosystem: bundler + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 +- package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000000..48f6abf003 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,150 @@ +name: CI + +on: + pull_request: + push: + branches: [ main ] + +jobs: + scan_ruby: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Scan for common Rails security vulnerabilities using static analysis + run: bin/brakeman --no-pager + + - name: Scan for known security vulnerabilities in gems used + run: bin/bundler-audit + + scan_js: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Scan for security vulnerabilities in JavaScript dependencies + run: bin/importmap audit + + lint: + runs-on: ubuntu-latest + env: + RUBOCOP_CACHE_ROOT: tmp/rubocop + steps: + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Prepare RuboCop cache + uses: actions/cache@v4 + env: + DEPENDENCIES_HASH: ${{ hashFiles('.ruby-version', '**/.rubocop.yml', '**/.rubocop_todo.yml', 'Gemfile.lock') }} + with: + path: ${{ env.RUBOCOP_CACHE_ROOT }} + key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }} + restore-keys: | + rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}- + + - name: Lint code for consistent style + run: bin/rubocop -f github + + test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + # redis: + # image: valkey/valkey:8 + # ports: + # - 6379:6379 + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y default-libmysqlclient-dev libvips + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Run tests + env: + RAILS_ENV: test + DATABASE_URL: mysql2://127.0.0.1:3306 + # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + # REDIS_URL: redis://localhost:6379/0 + run: bin/rails db:test:prepare test + + system-test: + runs-on: ubuntu-latest + + services: + mysql: + image: mysql + env: + MYSQL_ALLOW_EMPTY_PASSWORD: true + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + + # redis: + # image: valkey/valkey:8 + # ports: + # - 6379:6379 + # options: --health-cmd "redis-cli ping" --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - name: Install packages + run: sudo apt-get update && sudo apt-get install --no-install-recommends -y default-libmysqlclient-dev libvips + + - name: Checkout code + uses: actions/checkout@v6 + + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + bundler-cache: true + + - name: Run System Tests + env: + RAILS_ENV: test + DATABASE_URL: mysql2://127.0.0.1:3306 + # RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }} + # REDIS_URL: redis://localhost:6379/0 + run: bin/rails db:test:prepare test:system + + - name: Keep screenshots from failed system tests + uses: actions/upload-artifact@v4 + if: failure() + with: + name: screenshots + path: ${{ github.workspace }}/tmp/screenshots + if-no-files-found: ignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..8410f141a8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,40 @@ +# See https://help.github.com/articles/ignoring-files for more about ignoring files. +# +# Temporary files generated by your text editor or operating system +# belong in git's global ignore instead: +# `$XDG_CONFIG_HOME/git/ignore` or `~/.config/git/ignore` + +# Ignore system/IDE folders +.idea/ + +# Ignore bundler config. +/.bundle + +# Ignore all environment files (but keep .env.example in the repo). +/.env* +!/.env.example + +# Ignore all logfiles and tempfiles. +/log/* +/tmp/* +!/log/.keep +!/tmp/.keep + +# Ignore pidfiles, but keep the directory. +/tmp/pids/* +!/tmp/pids/ +!/tmp/pids/.keep + +# Ignore storage (uploaded files in development and any SQLite databases). +/storage/* +!/storage/.keep +/tmp/storage/* +!/tmp/storage/ +!/tmp/storage/.keep + +/public/assets + +# Ignore key files for decrypting credentials and more. +/config/*.key + +/vendor/bundle diff --git a/.kamal/hooks/docker-setup.sample b/.kamal/hooks/docker-setup.sample new file mode 100755 index 0000000000..2fb07d7d7a --- /dev/null +++ b/.kamal/hooks/docker-setup.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Docker set up on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/post-app-boot.sample b/.kamal/hooks/post-app-boot.sample new file mode 100755 index 0000000000..70f9c4bc95 --- /dev/null +++ b/.kamal/hooks/post-app-boot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Booted app version $KAMAL_VERSION on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/post-deploy.sample b/.kamal/hooks/post-deploy.sample new file mode 100755 index 0000000000..fd364c2a77 --- /dev/null +++ b/.kamal/hooks/post-deploy.sample @@ -0,0 +1,14 @@ +#!/bin/sh + +# A sample post-deploy hook +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) +# KAMAL_RUNTIME + +echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds" diff --git a/.kamal/hooks/post-proxy-reboot.sample b/.kamal/hooks/post-proxy-reboot.sample new file mode 100755 index 0000000000..1435a677f2 --- /dev/null +++ b/.kamal/hooks/post-proxy-reboot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Rebooted kamal-proxy on $KAMAL_HOSTS" diff --git a/.kamal/hooks/pre-app-boot.sample b/.kamal/hooks/pre-app-boot.sample new file mode 100755 index 0000000000..45f7355045 --- /dev/null +++ b/.kamal/hooks/pre-app-boot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Booting app version $KAMAL_VERSION on $KAMAL_HOSTS..." diff --git a/.kamal/hooks/pre-build.sample b/.kamal/hooks/pre-build.sample new file mode 100755 index 0000000000..c5a55678b2 --- /dev/null +++ b/.kamal/hooks/pre-build.sample @@ -0,0 +1,51 @@ +#!/bin/sh + +# A sample pre-build hook +# +# Checks: +# 1. We have a clean checkout +# 2. A remote is configured +# 3. The branch has been pushed to the remote +# 4. The version we are deploying matches the remote +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) + +if [ -n "$(git status --porcelain)" ]; then + echo "Git checkout is not clean, aborting..." >&2 + git status --porcelain >&2 + exit 1 +fi + +first_remote=$(git remote) + +if [ -z "$first_remote" ]; then + echo "No git remote set, aborting..." >&2 + exit 1 +fi + +current_branch=$(git branch --show-current) + +if [ -z "$current_branch" ]; then + echo "Not on a git branch, aborting..." >&2 + exit 1 +fi + +remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1) + +if [ -z "$remote_head" ]; then + echo "Branch not pushed to remote, aborting..." >&2 + exit 1 +fi + +if [ "$KAMAL_VERSION" != "$remote_head" ]; then + echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2 + exit 1 +fi + +exit 0 diff --git a/.kamal/hooks/pre-connect.sample b/.kamal/hooks/pre-connect.sample new file mode 100755 index 0000000000..77744bdca8 --- /dev/null +++ b/.kamal/hooks/pre-connect.sample @@ -0,0 +1,47 @@ +#!/usr/bin/env ruby + +# A sample pre-connect check +# +# Warms DNS before connecting to hosts in parallel +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) +# KAMAL_RUNTIME + +hosts = ENV["KAMAL_HOSTS"].split(",") +results = nil +max = 3 + +elapsed = Benchmark.realtime do + results = hosts.map do |host| + Thread.new do + tries = 1 + + begin + Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME) + rescue SocketError + if tries < max + puts "Retrying DNS warmup: #{host}" + tries += 1 + sleep rand + retry + else + puts "DNS warmup failed: #{host}" + host + end + end + + tries + end + end.map(&:value) +end + +retries = results.sum - hosts.size +nopes = results.count { |r| r == max } + +puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ] diff --git a/.kamal/hooks/pre-deploy.sample b/.kamal/hooks/pre-deploy.sample new file mode 100755 index 0000000000..05b3055b72 --- /dev/null +++ b/.kamal/hooks/pre-deploy.sample @@ -0,0 +1,122 @@ +#!/usr/bin/env ruby + +# A sample pre-deploy hook +# +# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds. +# +# Fails unless the combined status is "success" +# +# These environment variables are available: +# KAMAL_RECORDED_AT +# KAMAL_PERFORMER +# KAMAL_VERSION +# KAMAL_HOSTS +# KAMAL_COMMAND +# KAMAL_SUBCOMMAND +# KAMAL_ROLES (if set) +# KAMAL_DESTINATION (if set) + +# Only check the build status for production deployments +if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production" + exit 0 +end + +require "bundler/inline" + +# true = install gems so this is fast on repeat invocations +gemfile(true, quiet: true) do + source "https://rubygems.org" + + gem "octokit" + gem "faraday-retry" +end + +MAX_ATTEMPTS = 72 +ATTEMPTS_GAP = 10 + +def exit_with_error(message) + $stderr.puts message + exit 1 +end + +class GithubStatusChecks + attr_reader :remote_url, :git_sha, :github_client, :combined_status + + def initialize + @remote_url = github_repo_from_remote_url + @git_sha = `git rev-parse HEAD`.strip + @github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"]) + refresh! + end + + def refresh! + @combined_status = github_client.combined_status(remote_url, git_sha) + end + + def state + combined_status[:state] + end + + def first_status_url + first_status = combined_status[:statuses].find { |status| status[:state] == state } + first_status && first_status[:target_url] + end + + def complete_count + combined_status[:statuses].count { |status| status[:state] != "pending"} + end + + def total_count + combined_status[:statuses].count + end + + def current_status + if total_count > 0 + "Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..." + else + "Build not started..." + end + end + + private + def github_repo_from_remote_url + url = `git config --get remote.origin.url`.strip.delete_suffix(".git") + if url.start_with?("https://github.com/") + url.delete_prefix("https://github.com/") + elsif url.start_with?("git@github.com:") + url.delete_prefix("git@github.com:") + else + url + end + end +end + + +$stdout.sync = true + +begin + puts "Checking build status..." + + attempts = 0 + checks = GithubStatusChecks.new + + loop do + case checks.state + when "success" + puts "Checks passed, see #{checks.first_status_url}" + exit 0 + when "failure" + exit_with_error "Checks failed, see #{checks.first_status_url}" + when "pending" + attempts += 1 + end + + exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS + + puts checks.current_status + sleep(ATTEMPTS_GAP) + checks.refresh! + end +rescue Octokit::NotFound + exit_with_error "Build status could not be found" +end diff --git a/.kamal/hooks/pre-proxy-reboot.sample b/.kamal/hooks/pre-proxy-reboot.sample new file mode 100755 index 0000000000..061f8059e6 --- /dev/null +++ b/.kamal/hooks/pre-proxy-reboot.sample @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Rebooting kamal-proxy on $KAMAL_HOSTS..." diff --git a/.kamal/secrets b/.kamal/secrets new file mode 100644 index 0000000000..b3089d6f5a --- /dev/null +++ b/.kamal/secrets @@ -0,0 +1,20 @@ +# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets, +# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either +# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git. + +# Example of extracting secrets from 1password (or another compatible pw manager) +# SECRETS=$(kamal secrets fetch --adapter 1password --account your-account --from Vault/Item KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY) +# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD ${SECRETS}) +# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY ${SECRETS}) + +# Example of extracting secrets from Rails credentials +# KAMAL_REGISTRY_PASSWORD=$(rails credentials:fetch kamal.registry_password) + +# Use a GITHUB_TOKEN if private repositories are needed for the image +# GITHUB_TOKEN=$(gh config get -h github.com oauth_token) + +# Grab the registry password from ENV +# KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD + +# Improve security by using a password manager. Never check config/master.key into git! +RAILS_MASTER_KEY=$(cat config/master.key) diff --git a/.rspec b/.rspec new file mode 100644 index 0000000000..c99d2e7396 --- /dev/null +++ b/.rspec @@ -0,0 +1 @@ +--require spec_helper diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000000..f9d86d4a54 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,8 @@ +# Omakase Ruby styling for Rails +inherit_gem: { rubocop-rails-omakase: rubocop.yml } + +# Overwrite or add rules to create your own house style +# +# # Use `[a, [b, c]]` not `[ a, [ b, c ] ]` +# Layout/SpaceInsideArrayLiteralBrackets: +# Enabled: false diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..4d54daddb6 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +4.0.2 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000000..c625035af4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,77 @@ +# syntax=docker/dockerfile:1 +# check=error=true + +# This Dockerfile is designed for production, not development. Use with Kamal or build'n'run by hand: +# docker build -t camaar . +# docker run -d -p 80:80 -e RAILS_MASTER_KEY= --name camaar camaar + +# For a containerized dev environment, see Dev Containers: https://guides.rubyonrails.org/getting_started_with_devcontainer.html + +# Make sure RUBY_VERSION matches the Ruby version in .ruby-version +ARG RUBY_VERSION=4.0.2 +FROM docker.io/library/ruby:$RUBY_VERSION-slim AS base + +# Rails app lives here +WORKDIR /rails + +# Install base packages +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y curl default-mysql-client libjemalloc2 libvips && \ + ln -s /usr/lib/$(uname -m)-linux-gnu/libjemalloc.so.2 /usr/local/lib/libjemalloc.so && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives + +# Set production environment variables and enable jemalloc for reduced memory usage and latency. +ENV RAILS_ENV="production" \ + BUNDLE_DEPLOYMENT="1" \ + BUNDLE_PATH="/usr/local/bundle" \ + BUNDLE_WITHOUT="development" \ + LD_PRELOAD="/usr/local/lib/libjemalloc.so" + +# Throw-away build stage to reduce size of final image +FROM base AS build + +# Install packages needed to build gems +RUN apt-get update -qq && \ + apt-get install --no-install-recommends -y build-essential default-libmysqlclient-dev git libvips libyaml-dev pkg-config && \ + rm -rf /var/lib/apt/lists /var/cache/apt/archives + +# Install application gems +COPY vendor/* ./vendor/ +COPY Gemfile Gemfile.lock ./ + +RUN bundle install && \ + rm -rf ~/.bundle/ "${BUNDLE_PATH}"/ruby/*/cache "${BUNDLE_PATH}"/ruby/*/bundler/gems/*/.git && \ + # -j 1 disable parallel compilation to avoid a QEMU bug: https://github.com/rails/bootsnap/issues/495 + bundle exec bootsnap precompile -j 1 --gemfile + +# Copy application code +COPY . . + +# Precompile bootsnap code for faster boot times. +# -j 1 disable parallel compilation to avoid a QEMU bug: https://github.com/rails/bootsnap/issues/495 +RUN bundle exec bootsnap precompile -j 1 app/ lib/ + +# Precompiling assets for production without requiring secret RAILS_MASTER_KEY +RUN SECRET_KEY_BASE_DUMMY=1 ./bin/rails assets:precompile + + + + +# Final stage for app image +FROM base + +# Run and own only the runtime files as a non-root user for security +RUN groupadd --system --gid 1000 rails && \ + useradd rails --uid 1000 --gid 1000 --create-home --shell /bin/bash +USER 1000:1000 + +# Copy built artifacts: gems, application +COPY --chown=rails:rails --from=build "${BUNDLE_PATH}" "${BUNDLE_PATH}" +COPY --chown=rails:rails --from=build /rails /rails + +# Entrypoint prepares the database. +ENTRYPOINT ["/rails/bin/docker-entrypoint"] + +# Start server via Thruster by default, this can be overwritten at runtime +EXPOSE 80 +CMD ["./bin/thrust", "./bin/rails", "server"] diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..e7d3112a4a --- /dev/null +++ b/Gemfile @@ -0,0 +1,75 @@ +source "https://rubygems.org" + +# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main" +gem "rails", "~> 8.1.3" +# The modern asset pipeline for Rails [https://github.com/rails/propshaft] +gem "propshaft" +# Use mysql as the database for Active Record +gem "mysql2", "~> 0.5" +# Use the Puma web server [https://github.com/puma/puma] +gem "puma", ">= 5.0" +# Use JavaScript with ESM import maps [https://github.com/rails/importmap-rails] +gem "importmap-rails" +# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev] +gem "turbo-rails" +# Hotwire's modest JavaScript framework [https://stimulus.hotwired.dev] +gem "stimulus-rails" +# Build JSON APIs with ease [https://github.com/rails/jbuilder] +gem "jbuilder" + +# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword] +gem "bcrypt", "~> 3.1.7" + +# Windows does not include zoneinfo files, so bundle the tzinfo-data gem +gem "tzinfo-data", platforms: %i[ windows jruby ] + +# Use the database-backed adapters for Rails.cache, Active Job, and Action Cable +gem "solid_cache" +gem "solid_queue" +gem "solid_cable" + +# Reduces boot times through caching; required in config/boot.rb +gem "bootsnap", require: false + +gem 'csv' + +# Deploy this application anywhere as a Docker container [https://kamal-deploy.org] +gem "kamal", require: false + +# Add HTTP asset caching/compression and X-Sendfile acceleration to Puma [https://github.com/basecamp/thruster/] +gem "thruster", require: false + +# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images] +gem "image_processing", "~> 1.2" + +group :development, :test do + # See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem + gem "debug", platforms: %i[ mri windows ], require: "debug/prelude" + + # Load environment variables from .env file + gem "dotenv-rails" + + # Audits gems for known security defects (use config/bundler-audit.yml to ignore issues) + gem "bundler-audit", require: false + + # Static analysis for security vulnerabilities [https://brakemanscanner.org/] + gem "brakeman", require: false + + # Omakase Ruby styling [https://github.com/rails/rubocop-rails-omakase/] + gem "rubocop-rails-omakase", require: false +end + +group :development do + # Use console on exceptions pages [https://github.com/rails/web-console] + gem "web-console" + gem "rspec-rails" +end + +group :test do + # Use system testing [https://guides.rubyonrails.org/testing.html#system-testing] + gem "capybara" + gem "selenium-webdriver" + gem "cucumber-rails", require: false + gem "database_cleaner" + gem "rspec-rails" +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..7d7398f022 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,662 @@ +GEM + remote: https://rubygems.org/ + specs: + action_text-trix (2.1.19) + railties + actioncable (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + zeitwerk (~> 2.6) + actionmailbox (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + mail (>= 2.8.0) + actionmailer (8.1.3) + actionpack (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activesupport (= 8.1.3) + mail (>= 2.8.0) + rails-dom-testing (~> 2.2) + actionpack (8.1.3) + actionview (= 8.1.3) + activesupport (= 8.1.3) + nokogiri (>= 1.8.5) + rack (>= 2.2.4) + rack-session (>= 1.0.1) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + useragent (~> 0.16) + actiontext (8.1.3) + action_text-trix (~> 2.1.15) + actionpack (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (8.1.3) + activesupport (= 8.1.3) + builder (~> 3.1) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (8.1.3) + activesupport (= 8.1.3) + globalid (>= 0.3.6) + activemodel (8.1.3) + activesupport (= 8.1.3) + activerecord (8.1.3) + activemodel (= 8.1.3) + activesupport (= 8.1.3) + timeout (>= 0.4.0) + activestorage (8.1.3) + actionpack (= 8.1.3) + activejob (= 8.1.3) + activerecord (= 8.1.3) + activesupport (= 8.1.3) + marcel (~> 1.0) + activesupport (8.1.3) + base64 + bigdecimal + concurrent-ruby (~> 1.0, >= 1.3.1) + connection_pool (>= 2.2.5) + drb + i18n (>= 1.6, < 2) + json + logger (>= 1.4.2) + minitest (>= 5.1) + securerandom (>= 0.3) + tzinfo (~> 2.0, >= 2.0.5) + uri (>= 0.13.1) + addressable (2.9.0) + public_suffix (>= 2.0.2, < 8.0) + ast (2.4.3) + base64 (0.3.0) + bcrypt (3.1.22) + bcrypt_pbkdf (1.1.2) + bigdecimal (4.1.2) + bindex (0.8.1) + bootsnap (1.24.6) + msgpack (~> 1.2) + brakeman (8.0.5) + racc + builder (3.3.0) + bundler-audit (0.9.3) + bundler (>= 1.2.0) + thor (~> 1.0) + capybara (3.40.0) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.11) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + concurrent-ruby (1.3.6) + connection_pool (3.0.2) + crass (1.0.6) + csv (3.3.5) + cucumber (10.2.0) + base64 (~> 0.2) + builder (~> 3.2) + cucumber-ci-environment (> 9, < 12) + cucumber-core (> 15, < 17) + cucumber-cucumber-expressions (> 17, < 20) + cucumber-html-formatter (> 21, < 23) + diff-lcs (~> 1.5) + logger (~> 1.6) + mini_mime (~> 1.1) + multi_test (~> 1.1) + sys-uname (~> 1.3) + cucumber-ci-environment (11.0.0) + cucumber-core (16.2.0) + cucumber-gherkin (> 36, < 40) + cucumber-messages (> 31, < 33) + cucumber-tag-expressions (> 6, < 9) + cucumber-cucumber-expressions (19.0.1) + bigdecimal + cucumber-gherkin (39.1.0) + cucumber-messages (>= 31, < 33) + cucumber-html-formatter (22.3.0) + cucumber-messages (> 23, < 33) + cucumber-messages (32.3.1) + cucumber-rails (4.0.1) + capybara (>= 3.25, < 4) + cucumber (>= 7, < 11) + railties (>= 6.1, < 9) + cucumber-tag-expressions (8.1.0) + database_cleaner (2.1.0) + database_cleaner-active_record (>= 2, < 3) + database_cleaner-active_record (2.2.2) + activerecord (>= 5.a) + database_cleaner-core (~> 2.0) + database_cleaner-core (2.1.0) + date (3.5.1) + debug (1.11.1) + irb (~> 1.10) + reline (>= 0.3.8) + diff-lcs (1.6.2) + dotenv (3.2.0) + dotenv-rails (3.2.0) + dotenv (= 3.2.0) + railties (>= 6.1) + drb (2.2.3) + ed25519 (1.4.0) + erb (6.0.4) + erubi (1.13.1) + et-orbi (1.4.0) + tzinfo + ffi (1.17.4-aarch64-linux-gnu) + ffi (1.17.4-aarch64-linux-musl) + ffi (1.17.4-arm-linux-gnu) + ffi (1.17.4-arm-linux-musl) + ffi (1.17.4-arm64-darwin) + ffi (1.17.4-x64-mingw-ucrt) + ffi (1.17.4-x86_64-linux-gnu) + ffi (1.17.4-x86_64-linux-musl) + fugit (1.12.2) + et-orbi (~> 1.4) + raabro (~> 1.4) + globalid (1.3.0) + activesupport (>= 6.1) + i18n (1.14.8) + concurrent-ruby (~> 1.0) + image_processing (1.14.0) + mini_magick (>= 4.9.5, < 6) + ruby-vips (>= 2.0.17, < 3) + importmap-rails (2.2.3) + actionpack (>= 6.0.0) + activesupport (>= 6.0.0) + railties (>= 6.0.0) + io-console (0.8.2) + irb (1.18.0) + pp (>= 0.6.0) + prism (>= 1.3.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.15.1) + actionview (>= 7.0.0) + activesupport (>= 7.0.0) + json (2.19.9) + kamal (2.11.0) + activesupport (>= 7.0) + base64 (~> 0.2) + bcrypt_pbkdf (~> 1.0) + concurrent-ruby (~> 1.2) + dotenv (~> 3.1) + ed25519 (~> 1.4) + net-ssh (~> 7.3) + sshkit (>= 1.23.0, < 2.0) + thor (~> 1.3) + zeitwerk (>= 2.6.18, < 3.0) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + logger (1.7.0) + loofah (2.25.1) + crass (~> 1.0.2) + nokogiri (>= 1.12.0) + mail (2.9.0) + logger + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.2.1) + matrix (0.4.3) + memoist3 (1.0.0) + mini_magick (5.3.1) + logger + mini_mime (1.1.5) + minitest (6.0.6) + drb (~> 2.0) + prism (~> 1.5) + msgpack (1.8.3) + multi_test (1.1.0) + mysql2 (0.5.7) + bigdecimal + net-imap (0.6.4.1) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-scp (4.1.0) + net-ssh (>= 2.6.5, < 8.0.0) + net-sftp (4.0.0) + net-ssh (>= 5.0.0, < 8.0.0) + net-smtp (0.5.1) + net-protocol + net-ssh (7.3.2) + nio4r (2.7.5) + nokogiri (1.19.3-aarch64-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-aarch64-linux-musl) + racc (~> 1.4) + nokogiri (1.19.3-arm-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-arm-linux-musl) + racc (~> 1.4) + nokogiri (1.19.3-arm64-darwin) + racc (~> 1.4) + nokogiri (1.19.3-x64-mingw-ucrt) + racc (~> 1.4) + nokogiri (1.19.3-x86_64-linux-gnu) + racc (~> 1.4) + nokogiri (1.19.3-x86_64-linux-musl) + racc (~> 1.4) + ostruct (0.6.3) + parallel (2.1.0) + parser (3.3.11.1) + ast (~> 2.4.1) + racc + pp (0.6.3) + prettyprint + prettyprint (0.2.0) + prism (1.9.0) + propshaft (1.3.2) + actionpack (>= 7.0.0) + activesupport (>= 7.0.0) + rack + psych (5.4.0) + date + stringio + public_suffix (7.0.5) + puma (8.0.2) + nio4r (~> 2.0) + raabro (1.4.0) + racc (1.8.1) + rack (3.2.6) + rack-session (2.1.2) + base64 (>= 0.1.0) + rack (>= 3.0.0) + rack-test (2.2.0) + rack (>= 1.3) + rackup (2.3.1) + rack (>= 3) + rails (8.1.3) + actioncable (= 8.1.3) + actionmailbox (= 8.1.3) + actionmailer (= 8.1.3) + actionpack (= 8.1.3) + actiontext (= 8.1.3) + actionview (= 8.1.3) + activejob (= 8.1.3) + activemodel (= 8.1.3) + activerecord (= 8.1.3) + activestorage (= 8.1.3) + activesupport (= 8.1.3) + bundler (>= 1.15.0) + railties (= 8.1.3) + rails-dom-testing (2.3.0) + activesupport (>= 5.0.0) + minitest + nokogiri (>= 1.6) + rails-html-sanitizer (1.7.0) + loofah (~> 2.25) + nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) + railties (8.1.3) + actionpack (= 8.1.3) + activesupport (= 8.1.3) + irb (~> 1.13) + rackup (>= 1.0.0) + rake (>= 12.2) + thor (~> 1.0, >= 1.2.2) + tsort (>= 0.2) + zeitwerk (~> 2.6) + rainbow (3.1.1) + rake (13.4.2) + rdoc (7.2.0) + erb + psych (>= 4.0.0) + tsort + regexp_parser (2.12.0) + reline (0.6.3) + io-console (~> 0.5) + rexml (3.4.4) + rspec-core (3.13.6) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.5) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-mocks (3.13.8) + diff-lcs (>= 1.2.0, < 2.0) + rspec-support (~> 3.13.0) + rspec-rails (8.0.4) + actionpack (>= 7.2) + activesupport (>= 7.2) + railties (>= 7.2) + rspec-core (>= 3.13.0, < 5.0.0) + rspec-expectations (>= 3.13.0, < 5.0.0) + rspec-mocks (>= 3.13.0, < 5.0.0) + rspec-support (>= 3.13.0, < 5.0.0) + rspec-support (3.13.7) + rubocop (1.87.0) + json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) + parallel (>= 1.10) + parser (>= 3.3.0.2) + rainbow (>= 2.2.2, < 4.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.49.0, < 2.0) + ruby-progressbar (~> 1.7) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.49.1) + parser (>= 3.3.7.2) + prism (~> 1.7) + rubocop-performance (1.26.1) + lint_roller (~> 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.47.1, < 2.0) + rubocop-rails (2.35.4) + activesupport (>= 4.2.0) + lint_roller (~> 1.1) + rack (>= 1.1) + rubocop (>= 1.75.0, < 2.0) + rubocop-ast (>= 1.44.0, < 2.0) + rubocop-rails-omakase (1.1.0) + rubocop (>= 1.72) + rubocop-performance (>= 1.24) + rubocop-rails (>= 2.30) + ruby-progressbar (1.13.0) + ruby-vips (2.3.0) + ffi (~> 1.12) + logger + rubyzip (3.4.0) + securerandom (0.4.1) + selenium-webdriver (4.44.0) + base64 (~> 0.2) + logger (~> 1.4) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 4.0) + websocket (~> 1.0) + solid_cable (4.0.0) + actioncable (>= 7.2) + activejob (>= 7.2) + activerecord (>= 7.2) + railties (>= 7.2) + solid_cache (1.0.10) + activejob (>= 7.2) + activerecord (>= 7.2) + railties (>= 7.2) + solid_queue (1.4.0) + activejob (>= 7.1) + activerecord (>= 7.1) + concurrent-ruby (>= 1.3.1) + fugit (~> 1.11) + railties (>= 7.1) + thor (>= 1.3.1) + sshkit (1.25.0) + base64 + logger + net-scp (>= 1.1.2) + net-sftp (>= 2.1.2) + net-ssh (>= 2.8.0) + ostruct + stimulus-rails (1.3.4) + railties (>= 6.0.0) + stringio (3.2.0) + sys-uname (1.5.1) + ffi (~> 1.1) + memoist3 (~> 1.0.0) + sys-uname (1.5.1-universal-mingw32) + ffi (~> 1.1) + memoist3 (~> 1.0.0) + win32ole + thor (1.5.0) + thruster (0.1.21) + thruster (0.1.21-aarch64-linux) + thruster (0.1.21-arm64-darwin) + thruster (0.1.21-x86_64-linux) + timeout (0.6.1) + tsort (0.2.0) + turbo-rails (2.0.23) + actionpack (>= 7.1.0) + railties (>= 7.1.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + tzinfo-data (1.2026.2) + tzinfo (>= 1.0.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.2.0) + uri (1.1.1) + useragent (0.16.11) + web-console (4.3.0) + actionview (>= 8.0.0) + bindex (>= 0.4.0) + railties (>= 8.0.0) + websocket (1.2.11) + websocket-driver (0.8.1) + base64 + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + win32ole (1.9.3) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.8.2) + +PLATFORMS + aarch64-linux + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin-25 + x64-mingw-ucrt + x86_64-linux + x86_64-linux-gnu + x86_64-linux-musl + +DEPENDENCIES + bcrypt (~> 3.1.7) + bootsnap + brakeman + bundler-audit + capybara + csv + cucumber-rails + database_cleaner + debug + dotenv-rails + image_processing (~> 1.2) + importmap-rails + jbuilder + kamal + mysql2 (~> 0.5) + propshaft + puma (>= 5.0) + rails (~> 8.1.3) + rspec-rails + rubocop-rails-omakase + selenium-webdriver + solid_cable + solid_cache + solid_queue + stimulus-rails + thruster + turbo-rails + tzinfo-data + web-console + +CHECKSUMS + action_text-trix (2.1.19) sha256=7012f59421009cf284aa651294896414d653a61a2417c9b8714c8476d2f74009 + actioncable (8.1.3) sha256=e5bc7f75e44e6a22de29c4f43176927c3a9ce4824464b74ed18d8226e75a80f0 + actionmailbox (8.1.3) sha256=df7da474eaa0e70df4ed5a6fef66eb3b3b0f2dbf7f14518deee8d77f1b4aae59 + actionmailer (8.1.3) sha256=831f724891bb70d0aaa4d76581a6321124b6a752cb655c9346aae5479318448d + actionpack (8.1.3) sha256=af998cae4d47c5d581a2cc363b5c77eb718b7c4b45748d81b1887b25621c29a3 + actiontext (8.1.3) sha256=d291019c00e1ea9e6463011fa214f6081a56d7b9a1d224e7d3f6384c1dafc7d2 + actionview (8.1.3) sha256=1347c88c7f3edb38100c5ce0e9fb5e62d7755f3edc1b61cce2eb0b2c6ea2fd5d + activejob (8.1.3) sha256=a149b1766aa8204c3c3da7309e4becd40fcd5529c348cffbf6c9b16b565fe8d3 + activemodel (8.1.3) sha256=90c05cbe4cef3649b8f79f13016191ea94c4525ce4a5c0fb7ef909c4b91c8219 + activerecord (8.1.3) sha256=8003be7b2466ba0a2a670e603eeb0a61dd66058fccecfc49901e775260ac70ab + activestorage (8.1.3) sha256=0564ce9309143951a67615e1bb4e090ee54b8befed417133cae614479b46384d + activesupport (8.1.3) sha256=21a5e0dfbd4c3ddd9e1317ec6a4d782fa226e7867dc70b0743acda81a1dca20e + addressable (2.9.0) sha256=7fdf6ac3660f7f4e867a0838be3f6cf722ace541dd97767fa42bc6cfa980c7af + ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383 + base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b + bcrypt (3.1.22) sha256=1f0072e88c2d705d94aff7f2c5cb02eb3f1ec4b8368671e19112527489f29032 + bcrypt_pbkdf (1.1.2) sha256=c2414c23ce66869b3eb9f643d6a3374d8322dfb5078125c82792304c10b94cf6 + bigdecimal (4.1.2) sha256=53d217666027eab4280346fba98e7d5b66baaae1b9c3c1c0ffe89d48188a3fbd + bindex (0.8.1) sha256=7b1ecc9dc539ed8bccfc8cb4d2732046227b09d6f37582ff12e50a5047ceb17e + bootsnap (1.24.6) sha256=c60bab88c70332290f0a2636a288f675299eb4f804a02a3c085b42eca9da164a + brakeman (8.0.5) sha256=03735f9690d3fd4b32d66aacbf0a6d15a84266bdd06b32c05c8ecc8f6021d2be + builder (3.3.0) sha256=497918d2f9dca528fdca4b88d84e4ef4387256d984b8154e9d5d3fe5a9c8835f + bundler-audit (0.9.3) sha256=81c8766c71e47d0d28a0f98c7eed028539f21a6ea3cd8f685eb6f42333c9b4e9 + capybara (3.40.0) sha256=42dba720578ea1ca65fd7a41d163dd368502c191804558f6e0f71b391054aeef + concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab + connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a + crass (1.0.6) sha256=dc516022a56e7b3b156099abc81b6d2b08ea1ed12676ac7a5657617f012bd45d + csv (3.3.5) sha256=6e5134ac3383ef728b7f02725d9872934f523cb40b961479f69cf3afa6c8e73f + cucumber (10.2.0) sha256=fdedbd31ecf40858b60f04853f2aa15c44f5c30bbac29c6a227fa1e7005a8158 + cucumber-ci-environment (11.0.0) sha256=0df79a9e1d0b015b3d9def680f989200d96fef206f4d19ccf86a338c4f71d1e2 + cucumber-core (16.2.0) sha256=592b58a95cf42feef8e5a349f68e363784ba3b6568ffbcf6776e38e136cf970b + cucumber-cucumber-expressions (19.0.1) sha256=648ec09045190d818fb797af46e1648148599fd67a086a34a7f0e647d9e36c8c + cucumber-gherkin (39.1.0) sha256=aed12a0c955d8563d80a012633c1a72075525f4d64d4cc983001df2181b379ed + cucumber-html-formatter (22.3.0) sha256=f9768ed05588dbd73a5f3824c2cc648bd86b00206e6972d743af8051281d0729 + cucumber-messages (32.3.1) sha256=ddc88e4c1cf7afb96c06005b92a4a6f221a2fa435a8b4ca04677d215fd82771c + cucumber-rails (4.0.1) sha256=bd3513ec47dc06188cc05703648cbc3560fb115f3f5cfb8b616065b4d6e8024d + cucumber-tag-expressions (8.1.0) sha256=9bd8c4b6654f8e5bf2a9c99329b6f32136a75e50cd39d4cfb3927d0fa9f52e21 + database_cleaner (2.1.0) sha256=1dcba26e3b1576da692fc6bac10136a4744da5bcc293d248aae19640c65d89cd + database_cleaner-active_record (2.2.2) sha256=88296b9f3088c31f7c0d4fcec10f68e4b71c96698043916de59b04debec10388 + database_cleaner-core (2.1.0) sha256=b2875266d9b26b716e8b669c883e01c5250839f6f2ec56422b5e79aa97fb6927 + date (3.5.1) sha256=750d06384d7b9c15d562c76291407d89e368dda4d4fff957eb94962d325a0dc0 + debug (1.11.1) sha256=2e0b0ac6119f2207a6f8ac7d4a73ca8eb4e440f64da0a3136c30343146e952b6 + diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962 + dotenv (3.2.0) sha256=e375b83121ea7ca4ce20f214740076129ab8514cd81378161f11c03853fe619d + dotenv-rails (3.2.0) sha256=657e25554ba622ffc95d8c4f1670286510f47f2edda9f68293c3f661b303beab + drb (2.2.3) sha256=0b00d6fdb50995fe4a45dea13663493c841112e4068656854646f418fda13373 + ed25519 (1.4.0) sha256=16e97f5198689a154247169f3453ef4cfd3f7a47481fde0ae33206cdfdcac506 + erb (6.0.4) sha256=38e3803694be357fe2bfe312487c74beaf9fb4e5beb3e22498952fe1645b95d9 + erubi (1.13.1) sha256=a082103b0885dbc5ecf1172fede897f9ebdb745a4b97a5e8dc63953db1ee4ad9 + et-orbi (1.4.0) sha256=6c7e3c90779821f9e3b324c5e96fda9767f72995d6ae435b96678a4f3e2de8bc + ffi (1.17.4-aarch64-linux-gnu) sha256=b208f06f91ffd8f5e1193da3cae3d2ccfc27fc36fba577baf698d26d91c080df + ffi (1.17.4-aarch64-linux-musl) sha256=9286b7a615f2676245283aef0a0a3b475ae3aae2bb5448baace630bb77b91f39 + ffi (1.17.4-arm-linux-gnu) sha256=d6dbddf7cb77bf955411af5f187a65b8cd378cb003c15c05697f5feee1cb1564 + ffi (1.17.4-arm-linux-musl) sha256=9d4838ded0465bef6e2426935f6bcc93134b6616785a84ffd2a3d82bc3cf6f95 + ffi (1.17.4-arm64-darwin) sha256=19071aaf1419251b0a46852abf960e77330a3b334d13a4ab51d58b31a937001b + ffi (1.17.4-x64-mingw-ucrt) sha256=f6ff9618cfccc494138bddade27aa06c74c6c7bc367a1ea1103d80c2fcb9ed35 + ffi (1.17.4-x86_64-linux-gnu) sha256=9d3db14c2eae074b382fa9c083fe95aec6e0a1451da249eab096c34002bc752d + ffi (1.17.4-x86_64-linux-musl) sha256=3fdf9888483de005f8ef8d1cf2d3b20d86626af206cbf780f6a6a12439a9c49e + fugit (1.12.2) sha256=643f2bf28db263bd400cbf8e0dd8b76b2c9b94bdb130e12d2394de04d9c20e5e + globalid (1.3.0) sha256=05c639ad6eb4594522a0b07983022f04aa7254626ab69445a0e493aa3786ff11 + i18n (1.14.8) sha256=285778639134865c5e0f6269e0b818256017e8cde89993fdfcbfb64d088824a5 + image_processing (1.14.0) sha256=754cc169c9c262980889bec6bfd325ed1dafad34f85242b5a07b60af004742fb + importmap-rails (2.2.3) sha256=7101be2a4dc97cf1558fb8f573a718404c5f6bcfe94f304bf1f39e444feeb16a + io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc + irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3 + jbuilder (2.15.1) sha256=2430bec28fb0cebacb5875b1009cf9d8bc3c303ccb810c4c8b062a4b51457637 + json (2.19.9) sha256=9b9025b7cdddafa38d316eca0b2358488e42d417045c1b90d216a9fefe46b79a + kamal (2.11.0) sha256=1408864425e0dec7e0a14d712a3b13f614e9f3a425b7661d3f9d287a51d7dd75 + language_server-protocol (3.17.0.5) sha256=fd1e39a51a28bf3eec959379985a72e296e9f9acfce46f6a79d31ca8760803cc + lint_roller (1.1.0) sha256=2c0c845b632a7d172cb849cc90c1bce937a28c5c8ccccb50dfd46a485003cc87 + logger (1.7.0) sha256=196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203 + loofah (2.25.1) sha256=d436c73dbd0c1147b16c4a41db097942d217303e1f7728704b37e4df9f6d2e04 + mail (2.9.0) sha256=6fa6673ecd71c60c2d996260f9ee3dd387d4673b8169b502134659ece6d34941 + marcel (1.2.1) sha256=1678e9360e32f9eafa917c80029e2f6d10b2715c66a4b87b6d0da9b9cd1f859f + matrix (0.4.3) sha256=a0d5ab7ddcc1973ff690ab361b67f359acbb16958d1dc072b8b956a286564c5b + memoist3 (1.0.0) sha256=686e42402cf150a362050c23143dc57b0ef88f8c344943ff8b7845792b50d56f + mini_magick (5.3.1) sha256=29395dfd76badcabb6403ee5aff6f681e867074f8f28ce08d78661e9e4a351c4 + mini_mime (1.1.5) sha256=8681b7e2e4215f2a159f9400b5816d85e9d8c6c6b491e96a12797e798f8bccef + minitest (6.0.6) sha256=153ea36d1d987a62942382b61075745042a2b3123b1cd48f4c3675af9cc7d6f1 + msgpack (1.8.3) sha256=8bda4a6428d3244e50d6bd55854d354edbada88a4e1f4f5731a39a0f86bee6a1 + multi_test (1.1.0) sha256=e9e550cdd863fb72becfe344aefdcd4cbd26ebf307847f4a6c039a4082324d10 + mysql2 (0.5.7) sha256=ba09ede515a0ae8a7192040a1b778c0fb0f025fa5877e9be895cd325fa5e9d7b + net-imap (0.6.4.1) sha256=29f0360d75a7efd3539f16ac1957dea5c0a51ddeceb348db4553c3120914ea0d + net-pop (0.1.2) sha256=848b4e982013c15b2f0382792268763b748cce91c9e91e36b0f27ed26420dff3 + net-protocol (0.2.2) sha256=aa73e0cba6a125369de9837b8d8ef82a61849360eba0521900e2c3713aa162a8 + net-scp (4.1.0) sha256=a99b0b92a1e5d360b0de4ffbf2dc0c91531502d3d4f56c28b0139a7c093d1a5d + net-sftp (4.0.0) sha256=65bb91c859c2f93b09826757af11b69af931a3a9155050f50d1b06d384526364 + net-smtp (0.5.1) sha256=ed96a0af63c524fceb4b29b0d352195c30d82dd916a42f03c62a3a70e5b70736 + net-ssh (7.3.2) sha256=65029e213c380e20e5fd92ece663934ab0a0fe888e0cd7cc6a5b664074362dd4 + nio4r (2.7.5) sha256=6c90168e48fb5f8e768419c93abb94ba2b892a1d0602cb06eef16d8b7df1dca1 + nokogiri (1.19.3-aarch64-linux-gnu) sha256=46b89e5d7b9e844c2ee360794240c6ea2a4e6fa0c5892a4ed487db621224b639 + nokogiri (1.19.3-aarch64-linux-musl) sha256=8392dfdcd21be7a94dbbe9ccc138dea01b97b24cb2dc02a114ca98bfb1d9a0b7 + nokogiri (1.19.3-arm-linux-gnu) sha256=3919d5ffc334ad778a4a9eb88fda7dcb8b1fb58c8a52ac640c6dcd2f038e774f + nokogiri (1.19.3-arm-linux-musl) sha256=9ce1cb6346bb9c67b1550eb537aa183ead91e4b6eadb2f36ade02d8dd2a79fb6 + nokogiri (1.19.3-arm64-darwin) sha256=71b9bd424b1b7abc18b05052a1a3cfd3627abdca62be280854cc411791357e42 + nokogiri (1.19.3-x64-mingw-ucrt) sha256=8bb7132cad356c879a1286eaabcb5e68326cb2490317984280fbc62f456d506a + nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976 + nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f + ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912 + parallel (2.1.0) sha256=b35258865c2e31134c5ecb708beaaf6772adf9d5efae28e93e99260877b09356 + parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54 + pp (0.6.3) sha256=2951d514450b93ccfeb1df7d021cae0da16e0a7f95ee1e2273719669d0ab9df6 + prettyprint (0.2.0) sha256=2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193 + prism (1.9.0) sha256=7b530c6a9f92c24300014919c9dcbc055bf4cdf51ec30aed099b06cd6674ef85 + propshaft (1.3.2) sha256=1d56a3e56a92c21bfc29caf07406b5386b00d4c47ddf357cf989a5a234b1389e + psych (5.4.0) sha256=14f72d69a611af663d7d70e4a7b67d9eb1f3ae9f8d916b478961d5a0075ba5b7 + public_suffix (7.0.5) sha256=1a8bb08f1bbea19228d3bed6e5ed908d1cb4f7c2726d18bd9cadf60bc676f623 + puma (8.0.2) sha256=c8ed871dfbbe66448ea9ffd46692342d9804d4071522b52b5331b7b6e7b686fb + raabro (1.4.0) sha256=d4fa9ff5172391edb92b242eed8be802d1934b1464061ae5e70d80962c5da882 + racc (1.8.1) sha256=4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f + rack (3.2.6) sha256=5ed78e1f73b2e25679bec7d45ee2d4483cc4146eb1be0264fc4d94cb5ef212c2 + rack-session (2.1.2) sha256=595434f8c0c3473ae7d7ac56ecda6cc6dfd9d37c0b2b5255330aa1576967ffe8 + rack-test (2.2.0) sha256=005a36692c306ac0b4a9350355ee080fd09ddef1148a5f8b2ac636c720f5c463 + rackup (2.3.1) sha256=6c79c26753778e90983761d677a48937ee3192b3ffef6bc963c0950f94688868 + rails (8.1.3) sha256=6d017ba5348c98fc909753a8169b21d44de14d2a0b92d140d1a966834c3c9cd3 + rails-dom-testing (2.3.0) sha256=8acc7953a7b911ca44588bf08737bc16719f431a1cc3091a292bca7317925c1d + rails-html-sanitizer (1.7.0) sha256=28b145cceaf9cc214a9874feaa183c3acba036c9592b19886e0e45efc62b1e89 + railties (8.1.3) sha256=913eb0e0cb520aac687ffd74916bd726d48fa21f47833c6292576ef6a286de22 + rainbow (3.1.1) sha256=039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a + rake (13.4.2) sha256=cb825b2bd5f1f8e91ca37bddb4b9aaf345551b4731da62949be002fa89283701 + rdoc (7.2.0) sha256=8650f76cd4009c3b54955eb5d7e3a075c60a57276766ebf36f9085e8c9f23192 + regexp_parser (2.12.0) sha256=35a916a1d63190ab5c9009457136ae5f3c0c7512d60291d0d1378ba18ce08ebb + reline (0.6.3) sha256=1198b04973565b36ec0f11542ab3f5cfeeec34823f4e54cebde90968092b1835 + rexml (3.4.4) sha256=19e0a2c3425dfbf2d4fc1189747bdb2f849b6c5e74180401b15734bc97b5d142 + rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d + rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836 + rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47 + rspec-rails (8.0.4) sha256=06235692fc0892683d3d34977e081db867434b3a24ae0dd0c6f3516bad4e22df + rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c + rubocop (1.87.0) sha256=b9d9ddf55116a513f8ef2c7ae660662d8b49301f118d3f0df61865b33a5c188d + rubocop-ast (1.49.1) sha256=4412f3ee70f6fe4546cc489548e0f6fcf76cafcfa80fa03af67098ffed755035 + rubocop-performance (1.26.1) sha256=cd19b936ff196df85829d264b522fd4f98b6c89ad271fa52744a8c11b8f71834 + rubocop-rails (2.35.4) sha256=3aeaa325439c89950e8327565682ea794065d08e2ecbbfe95032bfa295a35df5 + rubocop-rails-omakase (1.1.0) sha256=2af73ac8ee5852de2919abbd2618af9c15c19b512c4cfc1f9a5d3b6ef009109d + ruby-progressbar (1.13.0) sha256=80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33 + ruby-vips (2.3.0) sha256=e685ec02c13969912debbd98019e50492e12989282da5f37d05f5471442f5374 + rubyzip (3.4.0) sha256=6de39bc9eba302b635a476d16c9e16b0872ad24517c2f98f2b3a7ea23caff57b + securerandom (0.4.1) sha256=cc5193d414a4341b6e225f0cb4446aceca8e50d5e1888743fac16987638ea0b1 + selenium-webdriver (4.44.0) sha256=6f1df072529af369589c46f0e01132952aabb250cfd683c274d74dc1eb5d8477 + solid_cable (4.0.0) sha256=8379680ef6bf36e195eb876a6306ea290f87d5fa10bc4a757bc2a918f83229b5 + solid_cache (1.0.10) sha256=bc05a2fb3ac78a6f43cbb5946679cf9db67dd30d22939ededc385cb93e120d41 + solid_queue (1.4.0) sha256=e6a18d196f0b27cb6e3c77c5b31258b05fb634f8ed64fb1866ed164047216c2a + sshkit (1.25.0) sha256=c8c6543cdb60f91f1d277306d585dd11b6a064cb44eab0972827e4311ff96744 + stimulus-rails (1.3.4) sha256=765676ffa1f33af64ce026d26b48e8ffb2e0b94e0f50e9119e11d6107d67cb06 + stringio (3.2.0) sha256=c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1 + sys-uname (1.5.1) sha256=784d7e6491b0393c25cbbe5ac38324ac7be9fda083a6094832648af669386d7b + sys-uname (1.5.1-universal-mingw32) sha256=aceb618e3276da5eae0ce368e9f6fae8c1f3e9ef23a0595cb88db7b6ecd45f62 + thor (1.5.0) sha256=e3a9e55fe857e44859ce104a84675ab6e8cd59c650a49106a05f55f136425e73 + thruster (0.1.21) sha256=dc67928f36e5894844579a95e45637a5091db7a7ea05468ee8c2c6eb0a3f77cf + thruster (0.1.21-aarch64-linux) sha256=f5aff78fb7a6431ed3d6ab4bde03a89c461e9a73981dbc97d6990d85c3db235c + thruster (0.1.21-arm64-darwin) sha256=bd8db9f57fae2cbb3fe08ebab49cb47fe49608122dac23daf0ce709adfb9bfc8 + thruster (0.1.21-x86_64-linux) sha256=6e2fbcf826540a72d3710ae4db072c2333287ac2ee57e7e52f35bc10900d74a7 + timeout (0.6.1) sha256=78f57368a7e7bbadec56971f78a3f5ecbcfb59b7fcbb0a3ed6ddc08a5094accb + tsort (0.2.0) sha256=9650a793f6859a43b6641671278f79cfead60ac714148aabe4e3f0060480089f + turbo-rails (2.0.23) sha256=ee0d90733aafff056cf51ff11e803d65e43cae258cc55f6492020ec1f9f9315f + tzinfo (2.0.6) sha256=8daf828cc77bcf7d63b0e3bdb6caa47e2272dcfaf4fbfe46f8c3a9df087a829b + tzinfo-data (1.2026.2) sha256=7db0d3d3d53b8d7601fc183fccc8c6d056a3004e14eb59ea995bf6aec4ae10bc + unicode-display_width (3.2.0) sha256=0cdd96b5681a5949cdbc2c55e7b420facae74c4aaf9a9815eee1087cb1853c42 + unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f + uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 + useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 + web-console (4.3.0) sha256=e13b71301cdfc2093f155b5aa3a622db80b4672d1f2f713119cc7ec7ac6a6da4 + websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737 + websocket-driver (0.8.1) sha256=5ab238238ce230e5d4b262d2be39624c867914eab99171dc4952b58b577c2d96 + websocket-extensions (0.1.5) sha256=1c6ba63092cda343eb53fc657110c71c754c56484aad42578495227d717a8241 + win32ole (1.9.3) sha256=01f43dc5dc13806e6e58204f538b4a28f3d85968ea89074abc9a3cd118e94d96 + xpath (3.2.0) sha256=6dfda79d91bb3b949b947ecc5919f042ef2f399b904013eb3ef6d20dd3a4082e + zeitwerk (2.8.2) sha256=7212a61311083c604184b1ea2574b9aa05cd14f855a0841c06985cabe9181d12 + +BUNDLED WITH + 4.0.10 diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000000..9a5ea7383a --- /dev/null +++ b/Rakefile @@ -0,0 +1,6 @@ +# Add your own tasks in files placed in lib/tasks ending in .rake, +# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. + +require_relative "config/application" + +Rails.application.load_tasks diff --git a/app/assets/images/.keep b/app/assets/images/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/assets/images/icons/create.svg b/app/assets/images/icons/create.svg new file mode 100644 index 0000000000..117c7630c8 --- /dev/null +++ b/app/assets/images/icons/create.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/images/icons/edit.svg b/app/assets/images/icons/edit.svg new file mode 100644 index 0000000000..275fa03b2b --- /dev/null +++ b/app/assets/images/icons/edit.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/images/icons/trash.svg b/app/assets/images/icons/trash.svg new file mode 100644 index 0000000000..28e3f31b34 --- /dev/null +++ b/app/assets/images/icons/trash.svg @@ -0,0 +1,3 @@ + + + diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css new file mode 100644 index 0000000000..fe24a847f3 --- /dev/null +++ b/app/assets/stylesheets/application.css @@ -0,0 +1,474 @@ +/* + * This is a manifest file that'll be compiled into application.css. + * + * With Propshaft, assets are served efficiently without preprocessing steps. You can still include + * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard + * cascading order, meaning styles declared later in the document or manifest will override earlier ones, + * depending on specificity. + * + * Consider organizing styles into separate files for maintainability. + */ + +:root { + --purple: #6d2d71; + --purple-dark: #542357; + --purple-soft: #efe2ef; + --green: #77d17b; + --green-dark: #61bf65; + --bg: #e4e4e4; + --panel: #ffffff; + --text: #1f1f1f; + --muted: #6f6f6f; + --border: #dadada; + --shadow: 0 20px 40px rgba(0, 0, 0, 0.12); +} + +* { + box-sizing: border-box; +} + +html, +body { + margin: 0; + min-height: 100%; + background: var(--bg); + color: var(--text); + font-family: Arial, Helvetica, sans-serif; +} + +a { + color: inherit; + text-decoration: none; +} + +button, +input, +select, +textarea { + font: inherit; +} + +.flash { + position: fixed; + top: 18px; + right: 18px; + z-index: 50; + max-width: 420px; +} + +.flash__item { + margin-bottom: 10px; + padding: 12px 16px; + border-radius: 12px; + background: var(--panel); + box-shadow: var(--shadow); + border-left: 4px solid var(--green-dark); +} + +.flash__item--alert { + border-left-color: #d75f5f; +} + +.login-container { + min-height: 100vh; + display: grid; + place-items: center; + padding: 40px 24px; +} + +.login-card, +.landing-card, +.admin-panel, +.user-panel, +.modal-card { + background: var(--panel); + border-radius: 4px; + box-shadow: var(--shadow); +} + +.login-card { + width: min(700px, 100%); + min-height: 380px; + display: grid; + grid-template-columns: 1.05fr 1fr; + overflow: hidden; + background: var(--panel); + border-radius: 4px; + box-shadow: var(--shadow); +} + +.login-form { + padding: 40px 32px; +} + +.login-form h1 { + margin: 0 0 18px; + font-size: 26px; + font-weight: 700; +} + +.login-banner { + background: var(--purple); + color: #fff; + display: grid; + place-items: center; + text-align: center; + padding: 40px; +} + +.login-banner h2 { + margin: 0; + font-size: 40px; + line-height: 1.05; +} + +.login-form h2, +.section-title { + margin: 0 0 18px; + font-size: 26px; + font-weight: 700; +} + +.field { + margin-bottom: 14px; +} + +.field label { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 6px; +} + +.field input, +.field select, +.field textarea { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--border); + border-radius: 6px; + background: #fff; +} + +.field label { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 6px; +} + +.field input, +.field select, +.field textarea { + width: 100%; + padding: 10px 12px; + border: 1px solid var(--border); + border-radius: 6px; + background: #fff; +} + +.btn { + appearance: none; + border: 0; + border-radius: 4px; + padding: 10px 18px; + cursor: pointer; + font-weight: 700; + transition: + transform 120ms ease, + opacity 120ms ease; +} + +.btn:hover { + transform: translateY(-1px); +} + +.btn--primary { + background: var(--green); + color: #fff; +} + +.btn--secondary { + background: var(--purple); + color: #fff; +} + +.btn--ghost { + background: #f4f4f4; + color: var(--text); +} + +.btn--danger { + background: #dc6b6b; + color: #fff; +} + +.app-shell { + min-height: 100vh; + display: grid; + grid-template-columns: 220px 1fr; +} + +.sidebar { + background: var(--panel); + border-right: 1px solid var(--border); + padding-top: 8px; +} + +.sidebar__item { + display: block; + padding: 12px 16px; + text-align: center; + color: #444; +} + +.sidebar__item--active { + background: var(--purple); + color: #fff; +} + +.workspace { + min-width: 0; +} + +.topbar { + height: 60px; + padding: 0 18px; + background: #fff; + border-bottom: 1px solid var(--border); + display: flex; + align-items: center; + gap: 14px; +} + +.topbar__title { + font-size: 22px; + font-weight: 500; + margin-right: auto; +} + +.search-pill { + width: min(220px, 34vw); + height: 28px; + border: 1px solid #b8b8b8; + border-radius: 20px; + background: linear-gradient( + to right, + transparent 0%, + transparent 88%, + #efefef 88%, + #efefef 100% + ); +} + +.avatar { + width: 32px; + height: 32px; + border-radius: 50%; + background: var(--purple); + color: #fff; + display: grid; + place-items: center; + font-weight: 700; +} + +.workspace__body { + padding: 24px; +} + +.cards-grid, +.template-grid, +.form-grid, +.results-grid { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); + gap: 16px; +} + +.card, +.template-card, +.form-card, +.result-card, +.action-card { + background: #fff; + border-radius: 4px; + padding: 12px 14px; + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15); + min-height: 82px; +} + +.card__title, +.template-card__title, +.form-card__title, +.result-card__title { + font-size: 18px; + font-weight: 700; + line-height: 1.1; + margin-bottom: 2px; +} + +.card__meta, +.template-card__meta, +.form-card__meta, +.result-card__meta { + font-size: 12px; + color: var(--muted); +} + +.card__footer, +.template-card__footer, +.form-card__footer, +.result-card__footer { + margin-top: 10px; + display: flex; + gap: 8px; + align-items: center; + justify-content: space-between; +} + +.action-card { + display: grid; + place-items: center; + min-height: 96px; + color: var(--purple-dark); + font-size: 34px; + font-weight: 400; +} + +.dashboard-hero { + width: min(280px, 100%); + margin: 22px auto 0; + padding: 22px; + display: grid; + gap: 8px; +} + +.dashboard-actions { + display: grid; + gap: 8px; +} + +.dashboard-actions .btn { + width: 100%; +} + +.modal-page { + padding: 24px; + display: grid; + place-items: center; +} + +.modal-card { + width: min(730px, 100%); + padding: 20px 22px 18px; +} + +.modal-card--narrow { + width: min(420px, 100%); +} + +.question-block { + border-top: 1px solid var(--border); + padding-top: 18px; + margin-top: 18px; +} + +.question-block:first-of-type { + border-top: 0; + padding-top: 0; + margin-top: 0; +} + +.question-grid { + display: grid; + grid-template-columns: 1.3fr 1fr; + gap: 14px; +} + +.question-actions { + display: flex; + justify-content: center; + gap: 10px; + margin-top: 10px; +} + +.mini-actions { + display: flex; + gap: 8px; + justify-content: flex-end; +} + +.pill { + display: inline-flex; + align-items: center; + gap: 6px; + padding: 5px 10px; + border-radius: 999px; + background: #f2f2f2; + font-size: 12px; +} + +.page-heading { + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + margin-bottom: 18px; +} + +.page-heading h1 { + margin: 0; + font-size: 28px; +} + +.split-layout { + display: grid; + grid-template-columns: 280px 1fr; + gap: 20px; +} + +.summary-panel { + background: #fff; + padding: 20px; + border-radius: 4px; + box-shadow: var(--shadow); +} + +.form-question { + padding: 16px 0; + border-bottom: 1px solid #ececec; +} + +.form-question:last-child { + border-bottom: 0; +} + +.form-question__title { + margin: 0 0 10px; + font-size: 18px; + font-weight: 700; +} + +.radio-list { + display: grid; + gap: 8px; +} + +.radio-list label { + display: inline-flex; + align-items: center; + gap: 8px; +} + +.empty-state { + background: #fff; + border: 1px dashed #cfcfcf; + border-radius: 8px; + padding: 28px; + text-align: center; + color: var(--muted); +} + +.hidden { + display: none !important; +} diff --git a/app/assets/stylesheets/gerenciamento.css b/app/assets/stylesheets/gerenciamento.css new file mode 100644 index 0000000000..62a43f3997 --- /dev/null +++ b/app/assets/stylesheets/gerenciamento.css @@ -0,0 +1,435 @@ + +body, html { + margin: 0; + padding: 0; + height: 100vh; + font-family: 'Roboto', 'Poppins', sans-serif; + background: #DBDBDB; +} + +.admin-container { + display: flex; + flex-direction: column; + height: 100vh; + overflow: hidden; +} + +.admin-header { + height: 60px; + min-height: 60px; + background: #FFFFFF; + box-shadow: 0px 11px 10.7px rgba(0, 0, 0, 0.05); + display: flex; + justify-content: space-between; + align-items: center; + padding: 0 20px; + z-index: 10; +} + +.header-left, .header-right { + display: flex; + align-items: center; + gap: 24px; +} + +.tab-name { + font-size: 24px; + font-weight: 400; + color: #000000; + margin: 0; +} + +.search-container { + width: 271px; + height: 40px; + border: 1px solid #8E8E8E; + border-radius: 47px; + display: flex; + align-items: center; + padding: 0 15px; + box-sizing: border-box; +} + +.search-input { + border: none; + background: transparent; + outline: none; + width: 100%; + font-family: 'Roboto', sans-serif; + font-size: 14px; +} + +.user-avatar { + width: 44px; + height: 44px; + background: #6C2365; + border-radius: 50%; + display: flex; + justify-content: center; + align-items: center; + color: #FFFFFF; + font-size: 24px; + font-weight: 500; +} + +.admin-body { + display: flex; + flex: 1; + overflow: hidden; +} + +.admin-sidebar { + width: 257px; + min-width: 257px; + background: #FFFFFF; + display: flex; + flex-direction: column; + border-right: 1px solid #D9D9D9; + padding-top: 10px; +} + +.menu-item { + height: 46px; + display: flex; + justify-content: center; + align-items: center; + border-bottom: 1px solid #D9D9D9; + text-decoration: none; + color: #000000; + font-size: 16px; +} + +.menu-item.active { + background: #6C2365; + color: #FFFFFF; +} + +.admin-content { + flex: 1; + background: #DBDBDB; + padding: 25px 43px; + display: flex; + flex-direction: column; + align-items: center; + gap: 50px; + overflow-y: auto; +} + +.figma-card { + width: 462px; + height: 655px; + background: #FFFFFF; + border-radius: 8px; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: center; + padding-top: 40px; + gap: 15px; +} + +.btn-figma { + width: 302px; + height: 43px; + display: flex; + justify-content: center; + align-items: center; + border-radius: 6px; + font-family: 'Poppins', sans-serif; + font-weight: 500; + font-size: 16px; + text-decoration: none; + border: none; + cursor: pointer; + box-shadow: 0px 1px 2px rgba(105, 81, 255, 0.05); + background: #86EFAC; + color: #1e1e1e; + transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out; +} + +.btn-figma:hover { + background: #22C55E; + color: #F0FDF4; +} + +.flash-message.notice { + background-color: #d1fae5; + color: #065f46; + border: 1px solid #10b981; +} + +.flash-message.alert { + background-color: #fee2e2; + color: #991b1b; + border: 1px solid #ef4444; +} + +.templates-grid { + display: grid; + grid-template-columns: repeat(auto-fill, 278px); + gap: 50px; + padding: 25px 43px; + width: 100%; + justify-content: flex-start; +} + +.card { + width: 278px; + height: 82px; + background: #FFFFFF; + border-radius: 8px; + padding: 24px; + display: flex; + justify-content: space-between; + align-items: center; + box-sizing: border-box; +} + +.template-title { + font-family: 'Roboto', sans-serif; + font-size: 24px; + font-weight: 500; + margin: 0; + color: #000000; +} + +.template-semester { + font-family: 'Roboto', sans-serif; + font-size: 16px; + font-weight: 400; + margin: 5px 0 0 0; + color: #000000; +} + +.card-actions { + display: flex; + gap: 10px; +} + +.action-btn { + background: none; + border: none; + cursor: pointer; + font-size: 16px; +} + +.card-create-new { + width: 278px; + height: 82px; + background: #FFFFFF; + border-radius: 8px; + display: flex; + justify-content: center; + align-items: center; + text-decoration: none; + color: #000; + border: 2px dashed #000000; + box-sizing: border-box; +} + +.plus-icon { + font-size: 30px; + font-weight: bold; +} + +.icon-wrapper svg { + width: 14px; + height: 14px; + fill: #000000; + transition: fill 0.2s; +} + +.action-btn:hover .icon-wrapper svg { + fill: #6C2365; +} + +.template-modal { + width: 453px; + background: #FFFFFF; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); + padding: 20px; + margin: 85px auto; + border-radius: 8px; +} + +.form-group { + display: flex; + align-items: center; + gap: 10px; + margin-bottom: 20px; +} + +input[type="text"], .dropdown { + border: none; + border-bottom: 1px solid #000; + width: 280px; + padding: 5px; +} + +.btn-save { + background: #22C55E; + color: #F0FDF4; + border: none; + padding: 12px 18px; + border-radius: 6px; + width: 125px; + margin: 0 auto; + display: block; + cursor: pointer; +} + +.modal-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0, 0, 0, 0.3); + display: flex; + justify-content: center; + align-items: center; + z-index: 1000; +} + +.figma-form-card { + width: 453px; + background: #FFFFFF; + box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); + border-radius: 8px; + padding: 20px 24px; + display: flex; + flex-direction: column; + gap: 20px; +} + +.figma-form-content { + display: flex; + flex-direction: column; + gap: 20px; +} + +/* Nome do template */ +.form-header-group { + display: flex; + align-items: center; + gap: 15px; +} + +.figma-label { + font-family: 'Inter', sans-serif; + font-size: 14px; + color: #000000; + white-space: nowrap; +} + +.figma-input-line { + border: none; + border-bottom: 1px solid #000000; + width: 100%; + font-family: 'Roboto', sans-serif; + font-size: 13px; + padding: 5px 0; + outline: none; + background: transparent; +} + +.figma-input-line::placeholder { + color: #8E8E8E; +} + +/* Blocos de Questão */ +.question-block { + display: flex; + flex-direction: column; + gap: 14px; +} + +.question-title { + font-family: 'Roboto', sans-serif; + font-size: 16px; + font-weight: 500; + color: #000000; + margin: 0; +} + +.question-row { + display: flex; + align-items: center; + gap: 15px; +} + +.figma-label-small { + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #000000; + width: 50px; +} + +.figma-dropdown { + background: #FFFFFF; + border: 1px solid #E0E0E0; + border-radius: 8px; + padding: 6px 12px; + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #828282; + width: 163px; + outline: none; +} + +.figma-input-line-full { + border: none; + border-bottom: 1px solid #000000; + flex-grow: 1; + font-family: 'Roboto', sans-serif; + font-size: 13px; + padding: 5px 0; + outline: none; +} + +/* Botão roxo de adicionar (+) */ +.add-question-btn { + width: 34px; + height: 34px; + background: #6C2365; + color: #FFF; + display: flex; + justify-content: center; + align-items: center; + font-size: 20px; + font-weight: bold; + border-radius: 4px; + cursor: pointer; + margin: 0 auto; +} + +.submit-row { + display: flex; + justify-content: center; + margin-top: 10px; +} + +.btn-figma-success { + background: #22C55E; + color: #F0FDF4; + font-family: 'Poppins', sans-serif; + font-weight: 500; + font-size: 16px; + border: none; + border-radius: 6px; + padding: 10px 30px; + cursor: pointer; + box-shadow: 0px 1px 2px rgba(105, 81, 255, 0.05); +} + +.cancel-row { + display: flex; + justify-content: center; +} + +.btn-cancel { + font-family: 'Inter', sans-serif; + font-size: 12px; + color: #828282; + text-decoration: underline; +} \ No newline at end of file diff --git a/app/assets/stylesheets/login.css b/app/assets/stylesheets/login.css new file mode 100644 index 0000000000..a22f4ec6bf --- /dev/null +++ b/app/assets/stylesheets/login.css @@ -0,0 +1,94 @@ +body { + background: #efefef; + margin: 0; + font-family: Arial, sans-serif; +} + +.login-container { + width: 90%; + max-width: 1100px; + height: 500px; + + margin: 40px auto; + + display: flex; + + background: white; + border-radius: 10px; + + overflow: hidden; +} + +.login-form { + flex: 1; + + display: flex; + flex-direction: column; + justify-content: center; + + padding: 50px; +} + +.login-form h1 { + text-align: center; + margin-bottom: 40px; +} + +.field { + margin-bottom: 20px; +} + +.field label { + display: block; + margin-bottom: 8px; +} + +.field input { + width: 100%; + box-sizing: border-box; + + padding: 12px; + + border: 1px solid #ccc; + border-radius: 6px; +} + +.btn-login { + width: 100%; + + padding: 12px; + + border: none; + border-radius: 6px; + + background: #2ecc71; + color: white; + + cursor: pointer; + + font-size: 16px; +} + +.btn-login:hover { + opacity: 0.9; +} + +.btn-forgot { + margin-top: 15px; +} + +.login-banner { + flex: 1; + + background: #6d1f6d; + + display: flex; + justify-content: center; + align-items: center; +} + +.login-banner h2 { + color: white; + text-align: center; + font-size: 4rem; +} \ No newline at end of file diff --git a/app/assets/stylesheets/redefinir_senha.css b/app/assets/stylesheets/redefinir_senha.css new file mode 100644 index 0000000000..893bc54580 --- /dev/null +++ b/app/assets/stylesheets/redefinir_senha.css @@ -0,0 +1,83 @@ +html, +body { + margin: 0; + padding: 0; + height: 100%; + font-family: Arial, Helvetica, sans-serif; + background-color: #f5f5f5; +} + +.password-reset-container { + height: 100vh; + + display: flex; + justify-content: center; + align-items: center; +} + +.password-reset-box { + width: 100%; + max-width: 450px; + + background: white; + + padding: 40px; + + border-radius: 10px; + + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); + + box-sizing: border-box; +} + +.password-reset-box h1 { + text-align: center; + + margin-top: 0; + margin-bottom: 30px; + + font-size: 2rem; + font-weight: normal; +} + +.field { + display: flex; + flex-direction: column; + + margin-bottom: 20px; +} + +.field label { + margin-bottom: 8px; +} + +.field input { + padding: 12px; + + border: 1px solid #d0d0d0; + border-radius: 6px; + + font-size: 1rem; + box-sizing: border-box; +} + +.btn-submit { + width: 100%; + + padding: 12px; + + border: none; + border-radius: 6px; + + background-color: #6e1f69; + color: white; + + font-size: 1rem; + font-weight: bold; + + cursor: pointer; +} + +.btn-submit:hover { + opacity: 0.9; +} \ No newline at end of file diff --git a/app/controllers/admin/dashboard_controller.rb b/app/controllers/admin/dashboard_controller.rb new file mode 100644 index 0000000000..d6c731faa7 --- /dev/null +++ b/app/controllers/admin/dashboard_controller.rb @@ -0,0 +1,70 @@ +module Admin + class DashboardController < ApplicationController + before_action :require_admin + layout "gerenciamento" + + def index + @workspace = workspace + @forms = @workspace.forms + end + + def gerenciamento + end + + def sincronizar_sigaa + if request.get? + render :sincronizar_sigaa + elsif request.post? + processar_sincronizacao + end + end + + private + + def processar_sincronizacao + acao = params[:acao] + arquivo = params[:arquivo_sigaa] + + unless arquivo.present? + redirect_to admin_gerenciamento_path, alert: "Por favor, selecione um arquivo" + return + end + + temp_file = arquivo.path + resultado = case acao + when "importar" + SigaaImporter.import_from_files(temp_file, temp_file) + when "atualizar" + SigaaImporter.update_from_files(temp_file, temp_file) + else + "ação inválida" + end + + processar_resultado(resultado, acao) + end + + def processar_resultado(resultado, acao) + case resultado + when /alguns dados/i + if acao == "importar" + redirect_to admin_gerenciamento_path, notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + else + redirect_to admin_gerenciamento_path, notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + end + when /sucesso/i + if acao == "importar" + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + else + redirect_to admin_gerenciamento_path, notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + end + when /já existem/i + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + when /já estão atualizados/i + redirect_to admin_gerenciamento_path, alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + else + nome_acao = acao == "importar" ? "importação" : "atualização" + redirect_to admin_gerenciamento_path, alert: "erro informando que a #{nome_acao} falhou" + end + end + end +end diff --git a/app/controllers/admin/forms_controller.rb b/app/controllers/admin/forms_controller.rb new file mode 100644 index 0000000000..7a7d5d3cb3 --- /dev/null +++ b/app/controllers/admin/forms_controller.rb @@ -0,0 +1,73 @@ +require "securerandom" + +module Admin + class FormsController < ApplicationController + before_action :require_admin + layout "gerenciamento" + + def index + @workspace = workspace + @forms = @workspace.forms + end + + def new + @workspace = workspace + @form = blank_form + @templates = @workspace.templates + end + + def create + @workspace = workspace + @templates = @workspace.templates + @form = form_payload + @workspace.create_form(@form) + flash[:notice] = "Formulário criado com sucesso" + redirect_to admin_forms_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :new, status: :unprocessable_entity + end + + def publish + form = workspace.find_form(params[:id]) + raise ActiveRecord::RecordNotFound, "Formulário não encontrado" unless form + + form["active"] = true + workspace.persist! + flash[:notice] = "Formulário enviado com sucesso" + redirect_to admin_forms_path + end + + def results + @workspace = workspace + @form = @workspace.find_form(params[:id]) + redirect_to admin_forms_path, alert: "Formulário não encontrado" unless @form + end + + private + + def blank_form + { + "title" => "", + "semester" => "2026.1", + "professor" => "Professor", + "template_id" => @workspace.templates.first&.dig("id"), + "audience" => "aluno", + "recipients" => [] + } + end + + def form_payload + payload = params.require(:form).permit(:title, :semester, :professor, :template_id, :audience, recipients: []) + + { + "title" => payload[:title].to_s.strip, + "semester" => payload[:semester].to_s.strip, + "professor" => payload[:professor].to_s.strip, + "template_id" => payload[:template_id].to_s, + "audience" => payload[:audience].to_s, + "recipients" => Array(payload[:recipients]).map(&:to_s) + } + end + end +end diff --git a/app/controllers/admin/templates_controller.rb b/app/controllers/admin/templates_controller.rb new file mode 100644 index 0000000000..599c5cdc23 --- /dev/null +++ b/app/controllers/admin/templates_controller.rb @@ -0,0 +1,85 @@ +require "securerandom" + +module Admin + class TemplatesController < ApplicationController + before_action :require_admin + layout "gerenciamento" + + def index + @workspace = workspace + @templates = @workspace.templates + end + + def new + @workspace = workspace + @template = blank_template + end + + def create + @workspace = workspace + @template = template_payload + @template = @workspace.create_template(@template) + flash[:notice] = "Template criado com sucesso!" + redirect_to admin_templates_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :new, status: :unprocessable_entity + end + + def edit + @workspace = workspace + @template = @workspace.find_template(params[:id]) + redirect_to admin_templates_path, alert: "Template não encontrado" unless @template + end + + def update + @workspace = workspace + @template = @workspace.update_template(params[:id], template_payload) + flash[:notice] = "Template atualizado com sucesso!" + redirect_to admin_templates_path + rescue ArgumentError => e + flash.now[:alert] = e.message + @template = @workspace.find_template(params[:id]) || blank_template + render :edit, status: :unprocessable_entity + end + + def destroy + workspace.delete_template(params[:id]) + flash[:notice] = "Template deletado com sucesso!" + redirect_to admin_templates_path + end + + private + + def blank_template + { + "id" => nil, + "title" => "", + "semester" => "2026.1", + "questions" => [ + { "id" => SecureRandom.uuid, "title" => "Questão 1", "type" => "radio", "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] } + ] + } + end + + def template_payload + payload = params.require(:template).permit(:title, :semester, questions: {}) + questions = payload[:questions].to_h.values.map do |question| + options = question[:options].to_s.split(",").map(&:strip).reject(&:blank?) + + { + "id" => question[:id].presence || SecureRandom.uuid, + "title" => question[:title].to_s.strip, + "type" => question[:type].to_s, + "options" => options + } + end + + { + "title" => payload[:title].to_s.strip, + "semester" => payload[:semester].to_s.strip, + "questions" => questions + } + end + end +end diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb new file mode 100644 index 0000000000..a0e38d13fb --- /dev/null +++ b/app/controllers/admin_controller.rb @@ -0,0 +1,112 @@ +class AdminController < ApplicationController + layout "gerenciamento" + + before_action :set_admin + + def avaliacoes + end + + def gerenciamento + end + + def resultados + @admin = Administrador.find_by(id: session[:usuario_id]) + + if @admin + @formularios = Formulario.joins(turma: :disciplina).where(disciplinas: { departamento_id: @admin.departamento_id }).includes(turma: :disciplina) + else + redirect_to root_path, alert: "Acesso não autorizado." + end + end + + def exportar_csv + @formulario = Formulario.find_by(id: params[:id]) + + if @formulario + # O .includes carrega o usuário e também os resposta_elems junto com seus respectivo elemento_form + @respostas = RespostaForm.where(formulario_id: @formulario.id).includes(:usuario, resposta_elems: :elemento_form) + + if @formulario.resposta_forms.empty? + redirect_to admin_resultados_path, alert: "Falha na exportação: Este formulário ainda não possui respostas registradas." + return + end + + respond_to do |format| + format.csv do + num_turma = @formulario.turma&.numero_da_turma&.parameterize(separator: "_") || "sem_turma" + nome_materia = @formulario.turma&.disciplina&.nome&.parameterize(separator: "_") || "sem_materia" + nome_arquivo = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}.csv" + + # Força o download + response.headers["Content-Disposition"] = "attachment; filename=\"#{nome_arquivo}\"" + end + end + else + redirect_to admin_resultados_path, alert: "Formulário não encontrado" + end + end + + def sincronizar_sigaa + if request.get? + render :sincronizar_sigaa + elsif request.post? + processar_sincronizacao + end + end + + private + + def set_admin + @admin = Administrador.find(params[:admin_id]) + + if @admin.id != session[:usuario_id] + redirect_to inicio_path, alert: "Acesso negado! Você só pode acessar as suas próprias páginas." + end + end + + def processar_sincronizacao + acao = params[:acao] + arquivo = params[:arquivo_sigaa] + + unless arquivo.present? + redirect_to admin_gerenciamento_path, alert: "Por favor, selecione um arquivo" + return + end + + temp_file = arquivo.path + resultado = case acao + when "importar" + SigaaImporter.import_from_files(temp_file, temp_file) + when "atualizar" + SigaaImporter.update_from_files(temp_file, temp_file) + else + "ação inválida" + end + + processar_resultado(resultado, acao) + end + + def processar_resultado(resultado, acao) + case resultado + when /alguns dados/i + if acao == "importar" + redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso" + else + redirect_to admin_gerenciamento_path(@admin), notice: "alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso" + end + when /sucesso/i + if acao == "importar" + redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão presentes no sistema." + else + redirect_to admin_gerenciamento_path(@admin), notice: "As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA." + end + when /já existem/i + redirect_to admin_gerenciamento_path(@admin), alert: "os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente" + when /já estão atualizados/i + redirect_to admin_gerenciamento_path(@admin), alert: "os dados do SIGAA já estão atualizados e não serão atualizados novamente" + else + nome_acao = acao == "importar" ? "importação" : "atualização" + redirect_to admin_gerenciamento_path(@admin), alert: "erro informando que a #{nome_acao} falhou" + end + end +end diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb new file mode 100644 index 0000000000..4f3ffc5dc8 --- /dev/null +++ b/app/controllers/application_controller.rb @@ -0,0 +1,32 @@ +class ApplicationController < ActionController::Base + allow_browser versions: :modern + stale_when_importmap_changes + + helper_method :workspace, :current_user, :admin_signed_in? + + private + + def workspace + @workspace ||= Camaar::Workspace.new(session) + end + + def current_user + @current_user ||= Usuario.find_by(id: session[:usuario_id]) if session[:usuario_id] + end + + def admin_signed_in? + current_user&.is_a?(Administrador) + end + + def require_login + unless current_user + redirect_to root_path, alert: "Por favor, faça login primeiro" + end + end + + def require_admin + unless admin_signed_in? + redirect_to inicio_path, alert: "Acesso restrito a administradores" + end + end +end diff --git a/app/controllers/campo_forms_controller.rb b/app/controllers/campo_forms_controller.rb new file mode 100644 index 0000000000..de491c59e0 --- /dev/null +++ b/app/controllers/campo_forms_controller.rb @@ -0,0 +1,70 @@ +class CampoFormsController < ApplicationController + before_action :set_campo_form, only: %i[ show edit update destroy ] + + # GET /campo_forms or /campo_forms.json + def index + @campo_forms = CampoForm.all + end + + # GET /campo_forms/1 or /campo_forms/1.json + def show + end + + # GET /campo_forms/new + def new + @campo_form = CampoForm.new + end + + # GET /campo_forms/1/edit + def edit + end + + # POST /campo_forms or /campo_forms.json + def create + @campo_form = CampoForm.new(campo_form_params) + + respond_to do |format| + if @campo_form.save + format.html { redirect_to @campo_form, notice: "Campo form was successfully created." } + format.json { render :show, status: :created, location: @campo_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @campo_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /campo_forms/1 or /campo_forms/1.json + def update + respond_to do |format| + if @campo_form.update(campo_form_params) + format.html { redirect_to @campo_form, notice: "Campo form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @campo_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @campo_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /campo_forms/1 or /campo_forms/1.json + def destroy + @campo_form.destroy! + + respond_to do |format| + format.html { redirect_to campo_forms_path, notice: "Campo form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_campo_form + @campo_form = CampoForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def campo_form_params + params.expect(campo_form: [ :ordem, :enunciado, :elemento_form_id ]) + end +end diff --git a/app/controllers/campos_controller.rb b/app/controllers/campos_controller.rb new file mode 100644 index 0000000000..cabefcb40d --- /dev/null +++ b/app/controllers/campos_controller.rb @@ -0,0 +1,70 @@ +class CamposController < ApplicationController + before_action :set_campo, only: %i[ show edit update destroy ] + + # GET /campos or /campos.json + def index + @campos = Campo.all + end + + # GET /campos/1 or /campos/1.json + def show + end + + # GET /campos/new + def new + @campo = Campo.new + end + + # GET /campos/1/edit + def edit + end + + # POST /campos or /campos.json + def create + @campo = Campo.new(campo_params) + + respond_to do |format| + if @campo.save + format.html { redirect_to @campo, notice: "Campo was successfully created." } + format.json { render :show, status: :created, location: @campo } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @campo.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /campos/1 or /campos/1.json + def update + respond_to do |format| + if @campo.update(campo_params) + format.html { redirect_to @campo, notice: "Campo was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @campo } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @campo.errors, status: :unprocessable_content } + end + end + end + + # DELETE /campos/1 or /campos/1.json + def destroy + @campo.destroy! + + respond_to do |format| + format.html { redirect_to campos_path, notice: "Campo was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_campo + @campo = Campo.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def campo_params + params.expect(campo: [ :ordem, :enunciado, :tipo_elemento, :elemento_id ]) + end +end diff --git a/app/controllers/concerns/.keep b/app/controllers/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/controllers/cursos_controller.rb b/app/controllers/cursos_controller.rb new file mode 100644 index 0000000000..afdf4d6e91 --- /dev/null +++ b/app/controllers/cursos_controller.rb @@ -0,0 +1,70 @@ +class CursosController < ApplicationController + before_action :set_curso, only: %i[ show edit update destroy ] + + # GET /cursos or /cursos.json + def index + @cursos = Curso.all + end + + # GET /cursos/1 or /cursos/1.json + def show + end + + # GET /cursos/new + def new + @curso = Curso.new + end + + # GET /cursos/1/edit + def edit + end + + # POST /cursos or /cursos.json + def create + @curso = Curso.new(curso_params) + + respond_to do |format| + if @curso.save + format.html { redirect_to @curso, notice: "Curso was successfully created." } + format.json { render :show, status: :created, location: @curso } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @curso.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /cursos/1 or /cursos/1.json + def update + respond_to do |format| + if @curso.update(curso_params) + format.html { redirect_to @curso, notice: "Curso was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @curso } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @curso.errors, status: :unprocessable_content } + end + end + end + + # DELETE /cursos/1 or /cursos/1.json + def destroy + @curso.destroy! + + respond_to do |format| + format.html { redirect_to cursos_path, notice: "Curso was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_curso + @curso = Curso.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def curso_params + params.expect(curso: [ :codigo, :nome, :departamento_id ]) + end +end diff --git a/app/controllers/dashboard_controller.rb b/app/controllers/dashboard_controller.rb new file mode 100644 index 0000000000..b5c276a756 --- /dev/null +++ b/app/controllers/dashboard_controller.rb @@ -0,0 +1,6 @@ +class DashboardController < ApplicationController + def index + @workspace = workspace + @current_user = session[:current_user] + end +end diff --git a/app/controllers/definicao_senhas_controller.rb b/app/controllers/definicao_senhas_controller.rb new file mode 100644 index 0000000000..96cf9ae77e --- /dev/null +++ b/app/controllers/definicao_senhas_controller.rb @@ -0,0 +1,45 @@ +class DefinicaoSenhasController < ApplicationController + def edit + @usuario = Usuario.find_by(definicao_senha_token: params[:token]) + + return if @usuario.present? + + redirect_to root_path, alert: "Link de definição de senha inválido." + end + + def update + @usuario = Usuario.find_by(definicao_senha_token: params[:token]) + + if @usuario.blank? + redirect_to root_path, alert: "Link de definição de senha inválido." + return + end + + nova_senha = params[:senha].to_s + confirmacao = params[:senha_confirmation].to_s + + if nova_senha != confirmacao + flash.now[:alert] = "Falha na definição de senha: confirmação não confere" + render :edit, status: :unprocessable_content + return + end + + if nova_senha.length < 6 + flash.now[:alert] = "Falha na definição de senha: senha inválida" + render :edit, status: :unprocessable_content + return + end + + @usuario.senha = nova_senha + @usuario.senha_confirmation = confirmacao + @usuario.definicao_senha_token = nil + @usuario.definicao_senha_sent_at = nil + + if @usuario.save + redirect_to root_path, notice: "Senha definida com sucesso." + else + flash.now[:alert] = "Falha na definição de senha: senha inválida" + render :edit, status: :unprocessable_content + end + end +end diff --git a/app/controllers/departamentos_controller.rb b/app/controllers/departamentos_controller.rb new file mode 100644 index 0000000000..106c61bf2b --- /dev/null +++ b/app/controllers/departamentos_controller.rb @@ -0,0 +1,70 @@ +class DepartamentosController < ApplicationController + before_action :set_departamento, only: %i[ show edit update destroy ] + + # GET /departamentos or /departamentos.json + def index + @departamentos = Departamento.all + end + + # GET /departamentos/1 or /departamentos/1.json + def show + end + + # GET /departamentos/new + def new + @departamento = Departamento.new + end + + # GET /departamentos/1/edit + def edit + end + + # POST /departamentos or /departamentos.json + def create + @departamento = Departamento.new(departamento_params) + + respond_to do |format| + if @departamento.save + format.html { redirect_to @departamento, notice: "Departamento was successfully created." } + format.json { render :show, status: :created, location: @departamento } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @departamento.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /departamentos/1 or /departamentos/1.json + def update + respond_to do |format| + if @departamento.update(departamento_params) + format.html { redirect_to @departamento, notice: "Departamento was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @departamento } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @departamento.errors, status: :unprocessable_content } + end + end + end + + # DELETE /departamentos/1 or /departamentos/1.json + def destroy + @departamento.destroy! + + respond_to do |format| + format.html { redirect_to departamentos_path, notice: "Departamento was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_departamento + @departamento = Departamento.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def departamento_params + params.expect(departamento: [ :codigo, :nome ]) + end +end diff --git a/app/controllers/discentes_controller.rb b/app/controllers/discentes_controller.rb new file mode 100644 index 0000000000..08d886207d --- /dev/null +++ b/app/controllers/discentes_controller.rb @@ -0,0 +1,70 @@ +class DiscentesController < ApplicationController + before_action :set_discente, only: %i[ show edit update destroy ] + + # GET /discentes or /discentes.json + def index + @discentes = Discente.all + end + + # GET /discentes/1 or /discentes/1.json + def show + end + + # GET /discentes/new + def new + @discente = Discente.new + end + + # GET /discentes/1/edit + def edit + end + + # POST /discentes or /discentes.json + def create + @discente = Discente.new(discente_params) + + respond_to do |format| + if @discente.save + format.html { redirect_to @discente, notice: "Discente was successfully created." } + format.json { render :show, status: :created, location: @discente } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @discente.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /discentes/1 or /discentes/1.json + def update + respond_to do |format| + if @discente.update(discente_params) + format.html { redirect_to @discente, notice: "Discente was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @discente } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @discente.errors, status: :unprocessable_content } + end + end + end + + # DELETE /discentes/1 or /discentes/1.json + def destroy + @discente.destroy! + + respond_to do |format| + format.html { redirect_to discentes_path, notice: "Discente was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_discente + @discente = Discente.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def discente_params + params.expect(discente: [ :matricula, :email, :nome, :formacao, :curso_id ]) + end +end diff --git a/app/controllers/disciplinas_controller.rb b/app/controllers/disciplinas_controller.rb new file mode 100644 index 0000000000..5938a50d91 --- /dev/null +++ b/app/controllers/disciplinas_controller.rb @@ -0,0 +1,70 @@ +class DisciplinasController < ApplicationController + before_action :set_disciplina, only: %i[ show edit update destroy ] + + # GET /disciplinas or /disciplinas.json + def index + @disciplinas = Disciplina.all + end + + # GET /disciplinas/1 or /disciplinas/1.json + def show + end + + # GET /disciplinas/new + def new + @disciplina = Disciplina.new + end + + # GET /disciplinas/1/edit + def edit + end + + # POST /disciplinas or /disciplinas.json + def create + @disciplina = Disciplina.new(disciplina_params) + + respond_to do |format| + if @disciplina.save + format.html { redirect_to @disciplina, notice: "Disciplina was successfully created." } + format.json { render :show, status: :created, location: @disciplina } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @disciplina.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /disciplinas/1 or /disciplinas/1.json + def update + respond_to do |format| + if @disciplina.update(disciplina_params) + format.html { redirect_to @disciplina, notice: "Disciplina was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @disciplina } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @disciplina.errors, status: :unprocessable_content } + end + end + end + + # DELETE /disciplinas/1 or /disciplinas/1.json + def destroy + @disciplina.destroy! + + respond_to do |format| + format.html { redirect_to disciplinas_path, notice: "Disciplina was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_disciplina + @disciplina = Disciplina.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def disciplina_params + params.expect(disciplina: [ :codigo, :nome, :departamento_id ]) + end +end diff --git a/app/controllers/docentes_controller.rb b/app/controllers/docentes_controller.rb new file mode 100644 index 0000000000..2fc30c57d8 --- /dev/null +++ b/app/controllers/docentes_controller.rb @@ -0,0 +1,70 @@ +class DocentesController < ApplicationController + before_action :set_docente, only: %i[ show edit update destroy ] + + # GET /docentes or /docentes.json + def index + @docentes = Docente.all + end + + # GET /docentes/1 or /docentes/1.json + def show + end + + # GET /docentes/new + def new + @docente = Docente.new + end + + # GET /docentes/1/edit + def edit + end + + # POST /docentes or /docentes.json + def create + @docente = Docente.new(docente_params) + + respond_to do |format| + if @docente.save + format.html { redirect_to @docente, notice: "Docente was successfully created." } + format.json { render :show, status: :created, location: @docente } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @docente.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /docentes/1 or /docentes/1.json + def update + respond_to do |format| + if @docente.update(docente_params) + format.html { redirect_to @docente, notice: "Docente was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @docente } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @docente.errors, status: :unprocessable_content } + end + end + end + + # DELETE /docentes/1 or /docentes/1.json + def destroy + @docente.destroy! + + respond_to do |format| + format.html { redirect_to docentes_path, notice: "Docente was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_docente + @docente = Docente.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def docente_params + params.expect(docente: [ :matricula, :email, :nome, :formacao ]) + end +end diff --git a/app/controllers/elemento_forms_controller.rb b/app/controllers/elemento_forms_controller.rb new file mode 100644 index 0000000000..355d9573ff --- /dev/null +++ b/app/controllers/elemento_forms_controller.rb @@ -0,0 +1,70 @@ +class ElementoFormsController < ApplicationController + before_action :set_elemento_form, only: %i[ show edit update destroy ] + + # GET /elemento_forms or /elemento_forms.json + def index + @elemento_forms = ElementoForm.all + end + + # GET /elemento_forms/1 or /elemento_forms/1.json + def show + end + + # GET /elemento_forms/new + def new + @elemento_form = ElementoForm.new + end + + # GET /elemento_forms/1/edit + def edit + end + + # POST /elemento_forms or /elemento_forms.json + def create + @elemento_form = ElementoForm.new(elemento_form_params) + + respond_to do |format| + if @elemento_form.save + format.html { redirect_to @elemento_form, notice: "Elemento form was successfully created." } + format.json { render :show, status: :created, location: @elemento_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @elemento_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /elemento_forms/1 or /elemento_forms/1.json + def update + respond_to do |format| + if @elemento_form.update(elemento_form_params) + format.html { redirect_to @elemento_form, notice: "Elemento form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @elemento_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @elemento_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /elemento_forms/1 or /elemento_forms/1.json + def destroy + @elemento_form.destroy! + + respond_to do |format| + format.html { redirect_to elemento_forms_path, notice: "Elemento form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_elemento_form + @elemento_form = ElementoForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def elemento_form_params + params.expect(elemento_form: [ :ordem, :enunciado, :formulario_id ]) + end +end diff --git a/app/controllers/elementos_controller.rb b/app/controllers/elementos_controller.rb new file mode 100644 index 0000000000..4357f9c17a --- /dev/null +++ b/app/controllers/elementos_controller.rb @@ -0,0 +1,70 @@ +class ElementosController < ApplicationController + before_action :set_elemento, only: %i[ show edit update destroy ] + + # GET /elementos or /elementos.json + def index + @elementos = Elemento.all + end + + # GET /elementos/1 or /elementos/1.json + def show + end + + # GET /elementos/new + def new + @elemento = Elemento.new + end + + # GET /elementos/1/edit + def edit + end + + # POST /elementos or /elementos.json + def create + @elemento = Elemento.new(elemento_params) + + respond_to do |format| + if @elemento.save + format.html { redirect_to @elemento, notice: "Elemento was successfully created." } + format.json { render :show, status: :created, location: @elemento } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @elemento.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /elementos/1 or /elementos/1.json + def update + respond_to do |format| + if @elemento.update(elemento_params) + format.html { redirect_to @elemento, notice: "Elemento was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @elemento } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @elemento.errors, status: :unprocessable_content } + end + end + end + + # DELETE /elementos/1 or /elementos/1.json + def destroy + @elemento.destroy! + + respond_to do |format| + format.html { redirect_to elementos_path, notice: "Elemento was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_elemento + @elemento = Elemento.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def elemento_params + params.expect(elemento: [ :ordem, :enunciado, :template_id ]) + end +end diff --git a/app/controllers/forms_controller.rb b/app/controllers/forms_controller.rb new file mode 100644 index 0000000000..0ef45b1e59 --- /dev/null +++ b/app/controllers/forms_controller.rb @@ -0,0 +1,37 @@ +require "securerandom" + +class FormsController < ApplicationController + def index + @workspace = workspace + @forms = @workspace.pending_forms + end + + def show + @workspace = workspace + @form = @workspace.find_form(params[:id]) + redirect_to forms_path, alert: "Formulário não encontrado" unless @form + end + + def create_response + @workspace = workspace + @form = @workspace.find_form(params[:id]) + raise ActiveRecord::RecordNotFound, "Formulário não encontrado" unless @form + + @workspace.record_response(@form["id"], response_payload) + flash[:notice] = "Avaliação enviada com sucesso" + redirect_to forms_path + rescue ArgumentError => e + flash.now[:alert] = e.message + render :show, status: :unprocessable_entity + end + + private + + def response_payload + payload = params.require(:response).permit(:comment, answers: {}) + { + "comment" => payload[:comment].to_s.strip, + "answers" => payload[:answers].to_h.transform_values { |value| value.to_s } + } + end +end diff --git a/app/controllers/formularios_controller.rb b/app/controllers/formularios_controller.rb new file mode 100644 index 0000000000..d50b937cf0 --- /dev/null +++ b/app/controllers/formularios_controller.rb @@ -0,0 +1,70 @@ +class FormulariosController < ApplicationController + before_action :set_formulario, only: %i[ show edit update destroy ] + + # GET /formularios or /formularios.json + def index + @formularios = Formulario.all + end + + # GET /formularios/1 or /formularios/1.json + def show + end + + # GET /formularios/new + def new + @formulario = Formulario.new + end + + # GET /formularios/1/edit + def edit + end + + # POST /formularios or /formularios.json + def create + @formulario = Formulario.new(formulario_params) + + respond_to do |format| + if @formulario.save + format.html { redirect_to @formulario, notice: "Formulario was successfully created." } + format.json { render :show, status: :created, location: @formulario } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @formulario.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /formularios/1 or /formularios/1.json + def update + respond_to do |format| + if @formulario.update(formulario_params) + format.html { redirect_to @formulario, notice: "Formulario was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @formulario } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @formulario.errors, status: :unprocessable_content } + end + end + end + + # DELETE /formularios/1 or /formularios/1.json + def destroy + @formulario.destroy! + + respond_to do |format| + format.html { redirect_to formularios_path, notice: "Formulario was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_formulario + @formulario = Formulario.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def formulario_params + params.expect(formulario: [ :turma_id ]) + end +end diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb new file mode 100644 index 0000000000..93633edc50 --- /dev/null +++ b/app/controllers/home_controller.rb @@ -0,0 +1,12 @@ +class HomeController < ApplicationController + before_action :require_login + + def index + @workspace = workspace + if admin_signed_in? + redirect_to admin_avaliacoes_path + else + @forms = @workspace.forms.select { |f| f["active"] } + end + end +end diff --git a/app/controllers/redefinicao_senhas_controller.rb b/app/controllers/redefinicao_senhas_controller.rb new file mode 100644 index 0000000000..29534249d5 --- /dev/null +++ b/app/controllers/redefinicao_senhas_controller.rb @@ -0,0 +1,67 @@ +class RedefinicaoSenhasController < ApplicationController + def new + end + + def create + email = params[:email].to_s.strip + + if email.blank? + redirect_to redefinir_senha_path, alert: "Falha na redefinição de senha: informe seu email" + return + end + + usuario = Usuario.find_by(email: email) + + if usuario.blank? + redirect_to redefinir_senha_path, alert: "Falha na redefinição de senha: usuário não encontrado" + return + end + + usuario.enviar_email_redefinicao_senha! + redirect_to root_path, notice: "Solicitação de redefinição de senha enviada." + end + + def edit + @usuario = Usuario.find_by(redefinicao_senha_token: params[:token]) + + return if @usuario.present? + + redirect_to root_path, alert: "Link de redefinição de senha inválido." + end + + def update + @usuario = Usuario.find_by(redefinicao_senha_token: params[:token]) + + if @usuario.blank? + redirect_to root_path, alert: "Link de redefinição de senha inválido." + return + end + + nova_senha = params[:senha].to_s + confirmacao = params[:senha_confirmation].to_s + + if nova_senha != confirmacao + flash.now[:alert] = "Falha na redefinição de senha: confirmação não confere" + render :edit, status: :unprocessable_content + return + end + + if nova_senha.length < 6 + flash.now[:alert] = "Falha na redefinição de senha: senha inválida" + render :edit, status: :unprocessable_content + return + end + + @usuario.senha = nova_senha + @usuario.senha_confirmation = confirmacao + @usuario.redefinicao_senha_token = nil + @usuario.redefinicao_senha_sent_at = nil + + if @usuario.save + redirect_to root_path, notice: "Senha redefinida com sucesso." + else + flash.now[:alert] = "Falha na redefinição de senha: senha inválida" + render :edit, status: :unprocessable_content + end + end +end diff --git a/app/controllers/resposta_elems_controller.rb b/app/controllers/resposta_elems_controller.rb new file mode 100644 index 0000000000..ebb155db99 --- /dev/null +++ b/app/controllers/resposta_elems_controller.rb @@ -0,0 +1,70 @@ +class RespostaElemsController < ApplicationController + before_action :set_resposta_elem, only: %i[ show edit update destroy ] + + # GET /resposta_elems or /resposta_elems.json + def index + @resposta_elems = RespostaElem.all + end + + # GET /resposta_elems/1 or /resposta_elems/1.json + def show + end + + # GET /resposta_elems/new + def new + @resposta_elem = RespostaElem.new + end + + # GET /resposta_elems/1/edit + def edit + end + + # POST /resposta_elems or /resposta_elems.json + def create + @resposta_elem = RespostaElem.new(resposta_elem_params) + + respond_to do |format| + if @resposta_elem.save + format.html { redirect_to @resposta_elem, notice: "Resposta elem was successfully created." } + format.json { render :show, status: :created, location: @resposta_elem } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @resposta_elem.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /resposta_elems/1 or /resposta_elems/1.json + def update + respond_to do |format| + if @resposta_elem.update(resposta_elem_params) + format.html { redirect_to @resposta_elem, notice: "Resposta elem was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @resposta_elem } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @resposta_elem.errors, status: :unprocessable_content } + end + end + end + + # DELETE /resposta_elems/1 or /resposta_elems/1.json + def destroy + @resposta_elem.destroy! + + respond_to do |format| + format.html { redirect_to resposta_elems_path, notice: "Resposta elem was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_resposta_elem + @resposta_elem = RespostaElem.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def resposta_elem_params + params.expect(resposta_elem: [ :texto_resposta, :resposta_form_id, :elemento_form_id, :campo_form_id ]) + end +end diff --git a/app/controllers/resposta_forms_controller.rb b/app/controllers/resposta_forms_controller.rb new file mode 100644 index 0000000000..16b541a220 --- /dev/null +++ b/app/controllers/resposta_forms_controller.rb @@ -0,0 +1,70 @@ +class RespostaFormsController < ApplicationController + before_action :set_resposta_form, only: %i[ show edit update destroy ] + + # GET /resposta_forms or /resposta_forms.json + def index + @resposta_forms = RespostaForm.all + end + + # GET /resposta_forms/1 or /resposta_forms/1.json + def show + end + + # GET /resposta_forms/new + def new + @resposta_form = RespostaForm.new + end + + # GET /resposta_forms/1/edit + def edit + end + + # POST /resposta_forms or /resposta_forms.json + def create + @resposta_form = RespostaForm.new(resposta_form_params) + + respond_to do |format| + if @resposta_form.save + format.html { redirect_to @resposta_form, notice: "Resposta form was successfully created." } + format.json { render :show, status: :created, location: @resposta_form } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @resposta_form.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /resposta_forms/1 or /resposta_forms/1.json + def update + respond_to do |format| + if @resposta_form.update(resposta_form_params) + format.html { redirect_to @resposta_form, notice: "Resposta form was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @resposta_form } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @resposta_form.errors, status: :unprocessable_content } + end + end + end + + # DELETE /resposta_forms/1 or /resposta_forms/1.json + def destroy + @resposta_form.destroy! + + respond_to do |format| + format.html { redirect_to resposta_forms_path, notice: "Resposta form was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_resposta_form + @resposta_form = RespostaForm.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def resposta_form_params + params.expect(resposta_form: [ :data_submissao, :formulario_id, :usuario_id ]) + end +end diff --git a/app/controllers/sessions_controller.rb b/app/controllers/sessions_controller.rb new file mode 100644 index 0000000000..83c9f03c80 --- /dev/null +++ b/app/controllers/sessions_controller.rb @@ -0,0 +1,49 @@ +class SessionsController < ApplicationController + def new + end + + def create + login = params[:login].to_s.strip + senha = params[:senha].to_s + + if login.blank? + redirect_to root_path, alert: "Falha no login: informe seu email ou matrícula" + return + end + + if senha.blank? + redirect_to root_path, alert: "Falha no login: informe a sua senha" + return + end + + usuario = Usuario.find_by(email: login) || Usuario.find_by(matricula: login) + + if usuario.blank? + redirect_to root_path, alert: "Falha no login: usuário não encontrado" + return + end + + unless usuario.senha_definida? + redirect_to root_path, alert: "Falha no login: usuário existente deve efetivar o seu cadastro por email" + return + end + + unless usuario.autenticar_senha(senha) + redirect_to root_path, alert: "Falha no login: senha incorreta" + return + end + + session[:usuario_id] = usuario.id + + if usuario.is_a?(Administrador) + redirect_to admin_avaliacoes_path, notice: "Login realizado com sucesso." + else + redirect_to inicio_path, notice: "Login realizado com sucesso." + end + end + + def destroy + reset_session + redirect_to root_path + end +end diff --git a/app/controllers/templates_controller.rb b/app/controllers/templates_controller.rb new file mode 100644 index 0000000000..b22654be3b --- /dev/null +++ b/app/controllers/templates_controller.rb @@ -0,0 +1,97 @@ +class TemplatesController < ApplicationController + layout "gerenciamento" + + before_action :set_admin + before_action :set_template, only: %i[ show edit update destroy ] + + # GET /templates or /templates.json + def index + @templates = @admin.templates.includes(elementos: :campos) + end + + # GET /templates/1 or /templates/1.json + def show + redirect_to admin_templates_path(@admin) + end + + # GET /templates/new + def new + @templates = @admin.templates + @template = @admin.templates.build + elemento = @template.elementos.build + elemento.campos.build + end + + # GET /templates/1/edit + def edit + @templates = @admin.templates + if @template.elementos.empty? + elemento = @template.elementos.build + elemento.campos.build + end + end + + # POST /templates or /templates.json + def create + @template = @admin.templates.build(template_params) + + respond_to do |format| + if @template.save + format.html { redirect_to admin_templates_path(@admin), notice: "Template criado com sucesso!" } + format.json { render :show, status: :created, location: @template } + else + @templates = @admin.templates + format.html { render :new, status: :unprocessable_content } + format.json { render json: @template.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /templates/1 or /templates/1.json + def update + respond_to do |format| + if @template.update(template_params) + format.html { redirect_to admin_templates_path(@admin), notice: "Template atualizado com sucesso!" } + format.json { render :show, status: :ok, location: @template } + else + @templates = @admin.templates + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @template.errors, status: :unprocessable_content } + end + end + end + + # DELETE /templates/1 or /templates/1.json + def destroy + @template.destroy! + respond_to do |format| + format.html { redirect_to admin_templates_path(@admin), notice: "Template deletado com sucesso!", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + + def set_admin + @admin = Administrador.find(params[:admin_id]) + if @admin.id != session[:usuario_id] + redirect_to inicio_path, alert: "Acesso negado! Você só pode acessar as suas próprias páginas." + end + end + + def set_template + @template = @admin.templates.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def template_params + params.require(:template).permit( + :nome, + elementos_attributes: [ + :id, :enunciado, :ordem, :_destroy, + campos_attributes: [ :id, :tipo_elemento, :enunciado, :ordem, :_destroy ] + ] + ) + end +end diff --git a/app/controllers/turmas_controller.rb b/app/controllers/turmas_controller.rb new file mode 100644 index 0000000000..5ba8d974ef --- /dev/null +++ b/app/controllers/turmas_controller.rb @@ -0,0 +1,70 @@ +class TurmasController < ApplicationController + before_action :set_turma, only: %i[ show edit update destroy ] + + # GET /turmas or /turmas.json + def index + @turmas = Turma.all + end + + # GET /turmas/1 or /turmas/1.json + def show + end + + # GET /turmas/new + def new + @turma = Turma.new + end + + # GET /turmas/1/edit + def edit + end + + # POST /turmas or /turmas.json + def create + @turma = Turma.new(turma_params) + + respond_to do |format| + if @turma.save + format.html { redirect_to @turma, notice: "Turma was successfully created." } + format.json { render :show, status: :created, location: @turma } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @turma.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /turmas/1 or /turmas/1.json + def update + respond_to do |format| + if @turma.update(turma_params) + format.html { redirect_to @turma, notice: "Turma was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @turma } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @turma.errors, status: :unprocessable_content } + end + end + end + + # DELETE /turmas/1 or /turmas/1.json + def destroy + @turma.destroy! + + respond_to do |format| + format.html { redirect_to turmas_path, notice: "Turma was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_turma + @turma = Turma.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def turma_params + params.expect(turma: [ :numero_da_turma, :semestre, :horario, :disciplina_id ]) + end +end diff --git a/app/controllers/usuarios_controller.rb b/app/controllers/usuarios_controller.rb new file mode 100644 index 0000000000..997075c07a --- /dev/null +++ b/app/controllers/usuarios_controller.rb @@ -0,0 +1,70 @@ +class UsuariosController < ApplicationController + before_action :set_usuario, only: %i[ show edit update destroy ] + + # GET /usuarios or /usuarios.json + def index + @usuarios = Usuario.all + end + + # GET /usuarios/1 or /usuarios/1.json + def show + end + + # GET /usuarios/new + def new + @usuario = Usuario.new + end + + # GET /usuarios/1/edit + def edit + end + + # POST /usuarios or /usuarios.json + def create + @usuario = Usuario.new(usuario_params) + + respond_to do |format| + if @usuario.save + format.html { redirect_to @usuario, notice: "Usuario was successfully created." } + format.json { render :show, status: :created, location: @usuario } + else + format.html { render :new, status: :unprocessable_content } + format.json { render json: @usuario.errors, status: :unprocessable_content } + end + end + end + + # PATCH/PUT /usuarios/1 or /usuarios/1.json + def update + respond_to do |format| + if @usuario.update(usuario_params) + format.html { redirect_to @usuario, notice: "Usuario was successfully updated.", status: :see_other } + format.json { render :show, status: :ok, location: @usuario } + else + format.html { render :edit, status: :unprocessable_content } + format.json { render json: @usuario.errors, status: :unprocessable_content } + end + end + end + + # DELETE /usuarios/1 or /usuarios/1.json + def destroy + @usuario.destroy! + + respond_to do |format| + format.html { redirect_to usuarios_path, notice: "Usuario was successfully destroyed.", status: :see_other } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_usuario + @usuario = Usuario.find(params.expect(:id)) + end + + # Only allow a list of trusted parameters through. + def usuario_params + params.expect(usuario: [ :matricula, :email, :nome, :formacao, :type ]) + end +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb new file mode 100644 index 0000000000..d5c6d3555d --- /dev/null +++ b/app/helpers/admin_helper.rb @@ -0,0 +1,2 @@ +module AdminHelper +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb new file mode 100644 index 0000000000..93a8e98dc2 --- /dev/null +++ b/app/helpers/application_helper.rb @@ -0,0 +1,11 @@ +module ApplicationHelper + def svg_icon(name, options = {}) + file_path = Rails.root.join("app", "assets", "images", "icons", "#{name}.svg") + if File.exist?(file_path) + svg = File.read(file_path).html_safe + content_tag(:span, svg, options.merge(class: "icon-wrapper #{options[:class]}")) + else + "(ícone não encontrado)" + end + end +end diff --git a/app/helpers/campo_forms_helper.rb b/app/helpers/campo_forms_helper.rb new file mode 100644 index 0000000000..4748406894 --- /dev/null +++ b/app/helpers/campo_forms_helper.rb @@ -0,0 +1,2 @@ +module CampoFormsHelper +end diff --git a/app/helpers/campos_helper.rb b/app/helpers/campos_helper.rb new file mode 100644 index 0000000000..dec4f22ced --- /dev/null +++ b/app/helpers/campos_helper.rb @@ -0,0 +1,2 @@ +module CamposHelper +end diff --git a/app/helpers/cursos_helper.rb b/app/helpers/cursos_helper.rb new file mode 100644 index 0000000000..4921eff347 --- /dev/null +++ b/app/helpers/cursos_helper.rb @@ -0,0 +1,2 @@ +module CursosHelper +end diff --git a/app/helpers/departamentos_helper.rb b/app/helpers/departamentos_helper.rb new file mode 100644 index 0000000000..df3b94bfda --- /dev/null +++ b/app/helpers/departamentos_helper.rb @@ -0,0 +1,2 @@ +module DepartamentosHelper +end diff --git a/app/helpers/discentes_helper.rb b/app/helpers/discentes_helper.rb new file mode 100644 index 0000000000..14d20c14c6 --- /dev/null +++ b/app/helpers/discentes_helper.rb @@ -0,0 +1,2 @@ +module DiscentesHelper +end diff --git a/app/helpers/disciplinas_helper.rb b/app/helpers/disciplinas_helper.rb new file mode 100644 index 0000000000..30b225dd00 --- /dev/null +++ b/app/helpers/disciplinas_helper.rb @@ -0,0 +1,2 @@ +module DisciplinasHelper +end diff --git a/app/helpers/docentes_helper.rb b/app/helpers/docentes_helper.rb new file mode 100644 index 0000000000..390c207243 --- /dev/null +++ b/app/helpers/docentes_helper.rb @@ -0,0 +1,2 @@ +module DocentesHelper +end diff --git a/app/helpers/elemento_forms_helper.rb b/app/helpers/elemento_forms_helper.rb new file mode 100644 index 0000000000..93783c1bcf --- /dev/null +++ b/app/helpers/elemento_forms_helper.rb @@ -0,0 +1,2 @@ +module ElementoFormsHelper +end diff --git a/app/helpers/elementos_helper.rb b/app/helpers/elementos_helper.rb new file mode 100644 index 0000000000..2f69e37c5b --- /dev/null +++ b/app/helpers/elementos_helper.rb @@ -0,0 +1,2 @@ +module ElementosHelper +end diff --git a/app/helpers/formularios_helper.rb b/app/helpers/formularios_helper.rb new file mode 100644 index 0000000000..3b96bb2209 --- /dev/null +++ b/app/helpers/formularios_helper.rb @@ -0,0 +1,2 @@ +module FormulariosHelper +end diff --git a/app/helpers/resposta_elems_helper.rb b/app/helpers/resposta_elems_helper.rb new file mode 100644 index 0000000000..cd6826fefc --- /dev/null +++ b/app/helpers/resposta_elems_helper.rb @@ -0,0 +1,2 @@ +module RespostaElemsHelper +end diff --git a/app/helpers/resposta_forms_helper.rb b/app/helpers/resposta_forms_helper.rb new file mode 100644 index 0000000000..800820446a --- /dev/null +++ b/app/helpers/resposta_forms_helper.rb @@ -0,0 +1,2 @@ +module RespostaFormsHelper +end diff --git a/app/helpers/templates_helper.rb b/app/helpers/templates_helper.rb new file mode 100644 index 0000000000..888093b832 --- /dev/null +++ b/app/helpers/templates_helper.rb @@ -0,0 +1,2 @@ +module TemplatesHelper +end diff --git a/app/helpers/turmas_helper.rb b/app/helpers/turmas_helper.rb new file mode 100644 index 0000000000..617e1373e9 --- /dev/null +++ b/app/helpers/turmas_helper.rb @@ -0,0 +1,2 @@ +module TurmasHelper +end diff --git a/app/helpers/usuarios_helper.rb b/app/helpers/usuarios_helper.rb new file mode 100644 index 0000000000..1f233ed026 --- /dev/null +++ b/app/helpers/usuarios_helper.rb @@ -0,0 +1,2 @@ +module UsuariosHelper +end diff --git a/app/javascript/application.js b/app/javascript/application.js new file mode 100644 index 0000000000..0d7b49404c --- /dev/null +++ b/app/javascript/application.js @@ -0,0 +1,3 @@ +// Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails +import "@hotwired/turbo-rails" +import "controllers" diff --git a/app/javascript/controllers/application.js b/app/javascript/controllers/application.js new file mode 100644 index 0000000000..1213e85c7a --- /dev/null +++ b/app/javascript/controllers/application.js @@ -0,0 +1,9 @@ +import { Application } from "@hotwired/stimulus" + +const application = Application.start() + +// Configure Stimulus development experience +application.debug = false +window.Stimulus = application + +export { application } diff --git a/app/javascript/controllers/hello_controller.js b/app/javascript/controllers/hello_controller.js new file mode 100644 index 0000000000..5975c0789d --- /dev/null +++ b/app/javascript/controllers/hello_controller.js @@ -0,0 +1,7 @@ +import { Controller } from "@hotwired/stimulus" + +export default class extends Controller { + connect() { + this.element.textContent = "Hello World!" + } +} diff --git a/app/javascript/controllers/index.js b/app/javascript/controllers/index.js new file mode 100644 index 0000000000..1156bf8362 --- /dev/null +++ b/app/javascript/controllers/index.js @@ -0,0 +1,4 @@ +// Import and register all your controllers from the importmap via controllers/**/*_controller +import { application } from "controllers/application" +import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading" +eagerLoadControllersFrom("controllers", application) diff --git a/app/jobs/application_job.rb b/app/jobs/application_job.rb new file mode 100644 index 0000000000..d394c3d106 --- /dev/null +++ b/app/jobs/application_job.rb @@ -0,0 +1,7 @@ +class ApplicationJob < ActiveJob::Base + # Automatically retry jobs that encountered a deadlock + # retry_on ActiveRecord::Deadlocked + + # Most jobs are safe to ignore if the underlying records are no longer available + # discard_on ActiveJob::DeserializationError +end diff --git a/app/mailers/application_mailer.rb b/app/mailers/application_mailer.rb new file mode 100644 index 0000000000..19b2c9e98c --- /dev/null +++ b/app/mailers/application_mailer.rb @@ -0,0 +1,4 @@ +class ApplicationMailer < ActionMailer::Base + default from: ENV.fetch("MAILER_FROM_ADDRESS", "camaar@gmail.com") + layout "mailer" +end diff --git a/app/mailers/usuario_mailer.rb b/app/mailers/usuario_mailer.rb new file mode 100644 index 0000000000..f9b99925c4 --- /dev/null +++ b/app/mailers/usuario_mailer.rb @@ -0,0 +1,15 @@ +class UsuarioMailer < ApplicationMailer + def definicao_senha(usuario) + @usuario = usuario + @url = edit_definicao_senha_url(token: usuario.definicao_senha_token) + + mail(to: usuario.email, subject: "Definição de senha") + end + + def redefinicao_senha(usuario) + @usuario = usuario + @url = edit_redefinicao_senha_url(token: usuario.redefinicao_senha_token) + + mail(to: usuario.email, subject: "Redefinição de senha") + end +end diff --git a/app/models/administrador.rb b/app/models/administrador.rb new file mode 100644 index 0000000000..414f77fc5f --- /dev/null +++ b/app/models/administrador.rb @@ -0,0 +1,4 @@ +class Administrador < Usuario + has_many :templates, foreign_key: "usuario_id", dependent: :destroy + validates :departamento_id, presence: true +end diff --git a/app/models/application_record.rb b/app/models/application_record.rb new file mode 100644 index 0000000000..b63caeb8a5 --- /dev/null +++ b/app/models/application_record.rb @@ -0,0 +1,3 @@ +class ApplicationRecord < ActiveRecord::Base + primary_abstract_class +end diff --git a/app/models/camaar/workspace.rb b/app/models/camaar/workspace.rb new file mode 100644 index 0000000000..99f25bab89 --- /dev/null +++ b/app/models/camaar/workspace.rb @@ -0,0 +1,219 @@ +require "securerandom" + +module Camaar + class Workspace + DEFAULT_STATE = { + "templates" => [ + { + "id" => "template-1", + "title" => "Template 1", + "semester" => "semestre", + "questions" => [ + { + "id" => "template-1-q1", + "title" => "Questão 1", + "type" => "radio", + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] + }, + { + "id" => "template-1-q2", + "title" => "Questão 2", + "type" => "text", + "options" => [] + } + ] + } + ], + "forms" => [ + { + "id" => "form-1", + "title" => "Avaliação de Turma 2026.1", + "semester" => "2026.1", + "professor" => "Professor", + "template_id" => "template-1", + "audience" => "aluno", + "active" => true, + "questions" => [ + { + "id" => "form-1-q1", + "title" => "Como você avalia o professor?", + "type" => "radio", + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] + } + ], + "responses" => [] + }, + { + "id" => "form-2", + "title" => "Nome da matéria", + "semester" => "semestre", + "professor" => "Professor", + "template_id" => "template-1", + "audience" => "aluno", + "active" => true, + "questions" => [ + { + "id" => "form-2-q1", + "title" => "Como você avalia o ambiente da disciplina?", + "type" => "radio", + "options" => [ "Ótimo", "Bom", "Regular", "Ruim" ] + } + ], + "responses" => [] + } + ] + }.freeze + + def initialize(_session = nil) + @record = WorkspaceState.instance + @record.data ||= DEFAULT_STATE.deep_dup + @record.save! if @record.new_record? + end + + def state + @record.data + end + + def templates + state["templates"] + end + + def forms + state["forms"] + end + + def recipients + state["recipients"] + end + + def pending_forms + forms.select { |form| form["active"] && form["responses"].empty? } + end + + def find_template(id) + templates.find { |template| template["id"] == id.to_s } + end + + def find_form(id) + forms.find { |form| form["id"] == id.to_s } + end + + def create_template(payload) + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + questions = normalize_questions(payload["questions"]) + raise ArgumentError, "Template deve ter pelo menos um elemento!" if questions.empty? + + template = { + "id" => SecureRandom.uuid, + "title" => title, + "semester" => payload["semester"].presence || "semestre", + "questions" => questions + } + + templates.unshift(template) + persist! + template + end + + def update_template(id, payload) + template = find_template(id) + raise ArgumentError, "Template não encontrado" unless template + + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + questions = normalize_questions(payload["questions"]) + raise ArgumentError, "Template deve ter pelo menos um elemento!" if questions.empty? + + template["title"] = title + template["semester"] = payload["semester"].presence || template["semester"] + template["questions"] = questions + persist! + template + end + + def delete_template(id) + templates.reject! { |template| template["id"] == id.to_s } + persist! + end + + def create_form(payload) + title = payload["title"].to_s.strip + raise ArgumentError, "Título não pode ficar em branco!" if title.blank? + + template = find_template(payload["template_id"]) + raise ArgumentError, "Template não encontrado" unless template + + form = { + "id" => SecureRandom.uuid, + "title" => title, + "semester" => payload["semester"].presence || template["semester"], + "professor" => payload["professor"].presence || "Professor", + "template_id" => template["id"], + "audience" => payload["audience"].presence || "aluno", + "active" => true, + "questions" => template["questions"].map(&:deep_dup), + "recipients" => Array(payload["recipients"]).map(&:to_s).reject(&:blank?), + "responses" => [] + } + + forms.unshift(form) + persist! + form + end + + def record_response(form_id, payload) + form = find_form(form_id) + raise ArgumentError, "Formulário não encontrado" unless form + + answers = payload["answers"] || {} + missing_questions = form["questions"].select do |question| + answer = answers[question["id"]] + question["type"] == "text" ? answer.to_s.strip.blank? : answer.to_s.strip.blank? + end + + if missing_questions.any? + raise ArgumentError, "Por favor, responda todas as perguntas obrigatórias" + end + + form["responses"] << { + "id" => SecureRandom.uuid, + "comment" => payload["comment"].to_s.strip, + "answers" => answers, + "created_at" => Time.current.iso8601 + } + persist! + form + end + + def persist! + @record.update!(data: state) + end + + private + + def normalize_questions(raw_questions) + questions_array = raw_questions.is_a?(Hash) ? raw_questions.values : Array(raw_questions) + questions_array.filter_map do |question| + next if question.nil? + + title = question["title"].to_s.strip + type = question["type"].to_s + options = Array(question["options"]).flat_map { |option| option.to_s.split(",") }.map(&:strip).reject(&:blank?) + + next if title.blank? + next if type == "radio" && options.size < 2 + + { + "id" => question["id"].presence || SecureRandom.uuid, + "title" => title, + "type" => type.presence || "radio", + "options" => options, + "required" => true + } + end + end + end +end diff --git a/app/models/campo.rb b/app/models/campo.rb new file mode 100644 index 0000000000..109cd4fc03 --- /dev/null +++ b/app/models/campo.rb @@ -0,0 +1,6 @@ +class Campo < ApplicationRecord + belongs_to :elemento + validates :ordem, presence: true + validates :ordem, uniqueness: { scope: :elemento_id } + validates :tipo_elemento, presence: true +end diff --git a/app/models/campo_form.rb b/app/models/campo_form.rb new file mode 100644 index 0000000000..f73b7e5efd --- /dev/null +++ b/app/models/campo_form.rb @@ -0,0 +1,5 @@ +class CampoForm < ApplicationRecord + belongs_to :elemento_form + has_many :resposta_elems, dependent: :destroy + validates :ordem, presence: true +end diff --git a/app/models/concerns/.keep b/app/models/concerns/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/app/models/curso.rb b/app/models/curso.rb new file mode 100644 index 0000000000..f854546b08 --- /dev/null +++ b/app/models/curso.rb @@ -0,0 +1,6 @@ +class Curso < ApplicationRecord + belongs_to :departamento + has_many :discentes + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end diff --git a/app/models/departamento.rb b/app/models/departamento.rb new file mode 100644 index 0000000000..1197a8801c --- /dev/null +++ b/app/models/departamento.rb @@ -0,0 +1,7 @@ +class Departamento < ApplicationRecord + has_many :cursos, dependent: :restrict_with_error + has_many :disciplinas, dependent: :restrict_with_error + has_many :administradores + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end diff --git a/app/models/discente.rb b/app/models/discente.rb new file mode 100644 index 0000000000..14fdfac827 --- /dev/null +++ b/app/models/discente.rb @@ -0,0 +1,4 @@ +class Discente < Usuario + validates :curso_id, presence: true + has_and_belongs_to_many :turmas, join_table: "discentes_turmas" +end diff --git a/app/models/disciplina.rb b/app/models/disciplina.rb new file mode 100644 index 0000000000..23741c99ea --- /dev/null +++ b/app/models/disciplina.rb @@ -0,0 +1,6 @@ +class Disciplina < ApplicationRecord + belongs_to :departamento + has_many :turmas, dependent: :destroy + validates :codigo, presence: true, uniqueness: true + validates :nome, presence: true +end diff --git a/app/models/docente.rb b/app/models/docente.rb new file mode 100644 index 0000000000..cd38cd2af5 --- /dev/null +++ b/app/models/docente.rb @@ -0,0 +1,4 @@ +class Docente < Usuario + validates :formacao, presence: true + has_and_belongs_to_many :turmas, join_table: "docentes_turmas" +end diff --git a/app/models/elemento.rb b/app/models/elemento.rb new file mode 100644 index 0000000000..135f84e8eb --- /dev/null +++ b/app/models/elemento.rb @@ -0,0 +1,5 @@ +class Elemento < ApplicationRecord + belongs_to :template + has_many :campos, dependent: :destroy + accepts_nested_attributes_for :campos, allow_destroy: true +end diff --git a/app/models/elemento_form.rb b/app/models/elemento_form.rb new file mode 100644 index 0000000000..7c232378d5 --- /dev/null +++ b/app/models/elemento_form.rb @@ -0,0 +1,5 @@ +class ElementoForm < ApplicationRecord + belongs_to :formulario + has_many :campo_forms, dependent: :destroy + validates :ordem, presence: true +end diff --git a/app/models/formulario.rb b/app/models/formulario.rb new file mode 100644 index 0000000000..87565cbd88 --- /dev/null +++ b/app/models/formulario.rb @@ -0,0 +1,5 @@ +class Formulario < ApplicationRecord + belongs_to :turma + has_many :elemento_forms, dependent: :destroy + has_many :resposta_forms, dependent: :destroy +end diff --git a/app/models/resposta_elem.rb b/app/models/resposta_elem.rb new file mode 100644 index 0000000000..569231b25d --- /dev/null +++ b/app/models/resposta_elem.rb @@ -0,0 +1,6 @@ +class RespostaElem < ApplicationRecord + belongs_to :resposta_form + belongs_to :elemento_form + belongs_to :campo_form, optional: true + validates :texto_resposta, presence: true +end diff --git a/app/models/resposta_form.rb b/app/models/resposta_form.rb new file mode 100644 index 0000000000..d4679476d1 --- /dev/null +++ b/app/models/resposta_form.rb @@ -0,0 +1,9 @@ +class RespostaForm < ApplicationRecord + belongs_to :formulario + belongs_to :usuario + has_many :resposta_elems, dependent: :destroy + validates :data_submissao, presence: true + validates :usuario_id, uniqueness: { + scope: :formulario_id + } +end diff --git a/app/models/template.rb b/app/models/template.rb new file mode 100644 index 0000000000..5b57dd4bcf --- /dev/null +++ b/app/models/template.rb @@ -0,0 +1,40 @@ +class Template < ApplicationRecord + belongs_to :administrador, foreign_key: "usuario_id", class_name: "Administrador" + has_many :elementos, dependent: :destroy + accepts_nested_attributes_for :elementos, allow_destroy: true + + validate :validar_titulo + validate :validar_elementos + validate :validar_preenchimento + + private + + def validar_titulo + if nome.blank? + errors.add(:base, "Título não pode ficar em branco!") + end + end + + def validar_elementos + if elementos.reject(&:marked_for_destruction?).empty? + errors.add(:base, "Template deve ter pelo menos um elemento!") + end + end + + def validar_preenchimento + return if errors.any? + elementos.reject(&:marked_for_destruction?).each do |elemento| + if elemento.enunciado.blank? + errors.add(:base, "O texto de todas as questões deve ser preenchido!") + return # Para a execução aqui para não repetir a mensagem várias vezes + end + + elemento.campos.reject(&:marked_for_destruction?).each do |campo| + if campo.tipo_elemento != "Texto" && campo.enunciado.blank? + errors.add(:base, "Todas as opções das questões devem ser preenchidas!") + return + end + end + end + end +end diff --git a/app/models/turma.rb b/app/models/turma.rb new file mode 100644 index 0000000000..09762e83c7 --- /dev/null +++ b/app/models/turma.rb @@ -0,0 +1,11 @@ +class Turma < ApplicationRecord + belongs_to :disciplina + has_many :formularios, dependent: :destroy + has_and_belongs_to_many :discentes, join_table: "discentes_turmas" + has_and_belongs_to_many :docentes, join_table: "docentes_turmas" + + validates :numero_da_turma, presence: true, uniqueness: { + scope: [ :semestre, :disciplina_id ] + } + validates :semestre, presence: true +end diff --git a/app/models/usuario.rb b/app/models/usuario.rb new file mode 100644 index 0000000000..2e3acbb079 --- /dev/null +++ b/app/models/usuario.rb @@ -0,0 +1,77 @@ +class Usuario < ApplicationRecord + belongs_to :curso, optional: true + belongs_to :departamento, optional: true + validates :matricula, presence: true, uniqueness: true + validates :email, presence: true, uniqueness: true + validates :nome, presence: true + + attr_reader :senha + attr_accessor :senha_confirmation + + before_save :atualizar_senha_hash, if: -> { senha.present? } + validate :validar_senha, if: -> { senha.present? } + + def senha=(nova_senha) + @senha = nova_senha + end + + def senha_definida? + senha_hash.present? + end + + def autenticar_senha(tentativa) + return false if senha_hash.blank? + + BCrypt::Password.new(senha_hash) == tentativa + rescue BCrypt::Errors::InvalidHash + false + end + + def gerar_definicao_senha_token! + update!( + definicao_senha_token: SecureRandom.urlsafe_base64(32), + definicao_senha_sent_at: Time.current + ) + end + + def enviar_email_definicao_senha! + gerar_definicao_senha_token! + UsuarioMailer.definicao_senha(self).deliver_now + end + + def gerar_redefinicao_senha_token! + update!( + redefinicao_senha_token: SecureRandom.urlsafe_base64(32), + redefinicao_senha_sent_at: Time.current + ) + end + + def enviar_email_redefinicao_senha! + gerar_redefinicao_senha_token! + UsuarioMailer.redefinicao_senha(self).deliver_now + end + + def limpar_redefinicao_senha_token! + update!(redefinicao_senha_token: nil, redefinicao_senha_sent_at: nil) + end + + def limpar_definicao_senha_token! + update!(definicao_senha_token: nil, definicao_senha_sent_at: nil) + end + + private + + def validar_senha + if senha_confirmation.present? && senha != senha_confirmation + errors.add(:senha, :confirmation, message: "confirmação não confere") + end + + if senha.length < 6 + errors.add(:senha, :invalid, message: "senha inválida") + end + end + + def atualizar_senha_hash + self.senha_hash = BCrypt::Password.create(senha) + end +end diff --git a/app/models/workspace_state.rb b/app/models/workspace_state.rb new file mode 100644 index 0000000000..d4a9270879 --- /dev/null +++ b/app/models/workspace_state.rb @@ -0,0 +1,5 @@ +class WorkspaceState < ApplicationRecord + def self.instance + first_or_create!(data: Camaar::Workspace::DEFAULT_STATE.deep_dup) + end +end diff --git a/app/services/sigaa_importer.rb b/app/services/sigaa_importer.rb new file mode 100644 index 0000000000..65d5991dbd --- /dev/null +++ b/app/services/sigaa_importer.rb @@ -0,0 +1,131 @@ +class SigaaImporter + def self.import_from_files(classes_path, members_path) + created = 0 + ignored = 0 + + ActiveRecord::Base.transaction do + dep_padrao = Departamento.find_or_create_by(codigo: "NAO_ESP") { |d| d.nome = "Não especificado" } + + # classes.json + classes = JSON.parse(File.read(classes_path)) + classes.each do |c| + disciplina = Disciplina.find_or_create_by(codigo: c["code"]) do |d| + d.nome = c["name"] + d.departamento = dep_padrao + end + + class_info = c["class"] || {} + turma = Turma.find_or_create_by(disciplina: disciplina, numero_da_turma: class_info["classCode"], semestre: class_info["semester"]) do |t| + t.horario = class_info["time"] + end + + if turma.created_at == turma.updated_at + created += 1 + else + ignored += 1 + end + end + + # class_members.json + members = JSON.parse(File.read(members_path)) + members.each do |m| + code = m.dig("class", "code") || m["code"] + class_code = m.dig("class", "classCode") || m["classCode"] + semester = m.dig("class", "semester") || m["semester"] + + disciplina = Disciplina.find_by(codigo: code) + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_code, semestre: semester) + next unless turma + + # docente + if m["docente"].is_a?(Hash) + dep = m["docente"]["departamento"].present? ? Departamento.find_or_create_by(nome: m["docente"]["departamento"]) : dep_padrao + docente = Docente.find_or_create_by(email: m["docente"]["email"]) do |dct| + dct.nome = m["docente"]["nome"] + dct.matricula = m["docente"]["matricula"] || m["docente"]["usuario"] + dct.formacao = m["docente"]["formacao"] || "docente" + dct.departamento = dep + end + unless docente.turmas.exists?(turma.id) + docente.turmas << turma + created += 1 + else + ignored += 1 + end + end + + # discentes + Array(m["dicente"]).each do |aluno| + next unless aluno.is_a?(Hash) + curso = Curso.find_or_create_by(nome: aluno["curso"]) { |c| c.departamento = dep_padrao } if aluno["curso"] + discente = Discente.find_or_create_by(matricula: aluno["matricula"]) do |d| + d.nome = aluno["nome"] + d.email = aluno["email"] + d.formacao = aluno["formacao"] || "graduando" + d.curso = curso if curso + end + unless discente.turmas.exists?(turma.id) + discente.turmas << turma + created += 1 + else + ignored += 1 + end + end + end + end + + if created > 0 && ignored > 0 + "alguns dados já foram importados e não serão importados novamente, mas os dados restantes foram importados com sucesso" + elsif created == 0 + "os dados já existem e não foram duplicados" + else + "importação realizada com sucesso" + end + rescue StandardError => _e + "a importação falhou" + end + + def self.update_from_files(classes_path, members_path) + ActiveRecord::Base.transaction do + classes = JSON.parse(File.read(classes_path)) + classes.each do |c| + disciplina = Disciplina.find_by(codigo: c["code"]) + disciplina.update(nome: c["name"]) if disciplina + + class_info = c["class"] || {} + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_info["classCode"], semestre: class_info["semester"]) + turma.update(horario: class_info["time"]) if turma + end + + members = JSON.parse(File.read(members_path)) + members.each do |m| + code = m.dig("class", "code") || m["code"] + class_code = m.dig("class", "classCode") || m["classCode"] + semester = m.dig("class", "semester") || m["semester"] + + disciplina = Disciplina.find_by(codigo: code) + turma = Turma.find_by(disciplina: disciplina, numero_da_turma: class_code, semestre: semester) + next unless turma + + if m["docente"].is_a?(Hash) + dep = Departamento.find_or_create_by(nome: m["docente"]["departamento"]) if m["docente"]["departamento"] + docente = Docente.find_by(email: m["docente"]["email"]) + docente.update(nome: m["docente"]["nome"], departamento: dep) if docente + docente.turmas << turma if docente && !docente.turmas.exists?(turma.id) + end + + Array(m["dicente"]).each do |aluno| + next unless aluno.is_a?(Hash) + curso = Curso.find_by(nome: aluno["curso"]) if aluno["curso"] + discente = Discente.find_by(matricula: aluno["matricula"]) + discente.update(nome: aluno["nome"], email: aluno["email"], curso: curso) if discente + discente.turmas << turma if discente && !discente.turmas.exists?(turma.id) + end + end + end + + "atualização realizada com sucesso" + rescue StandardError => _e + "a atualização falhou" + end +end diff --git a/app/views/admin/dashboard/avaliacoes.html.erb b/app/views/admin/dashboard/avaliacoes.html.erb new file mode 100644 index 0000000000..6d8619ebde --- /dev/null +++ b/app/views/admin/dashboard/avaliacoes.html.erb @@ -0,0 +1,35 @@ +
+

Avaliações do Sistema

+ <%= link_to "Criar Avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+
<%= form["responses"].size %> respostas
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhuma avaliação criada.

+ <%= link_to "Criar primeira avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/dashboard/gerenciamento.html.erb b/app/views/admin/dashboard/gerenciamento.html.erb new file mode 100644 index 0000000000..6bb49a55d2 --- /dev/null +++ b/app/views/admin/dashboard/gerenciamento.html.erb @@ -0,0 +1,23 @@ +
+

Ações de Gerenciamento

+
+ +
+
+ <%= link_to admin_sincronizar_sigaa_path, style: "text-decoration: none; color: inherit; width: 100%; height: 100%; display: grid; place-items: center;" do %> +
+
Importar / Atualizar
+
Dados do SIGAA
+
+ <% end %> +
+ +
+ <%= link_to admin_templates_path, style: "text-decoration: none; color: inherit; width: 100%; height: 100%; display: grid; place-items: center;" do %> +
+
Editar Templates
+
Gerenciar templates
+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/dashboard/index.html.erb b/app/views/admin/dashboard/index.html.erb new file mode 100644 index 0000000000..3c1f82989a --- /dev/null +++ b/app/views/admin/dashboard/index.html.erb @@ -0,0 +1,34 @@ +
+

Avaliações Criadas

+ <%= link_to "Criar Avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhuma avaliação criada ainda.

+ <%= link_to "Criar primeira avaliação", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/dashboard/sincronizar_sigaa.html.erb b/app/views/admin/dashboard/sincronizar_sigaa.html.erb new file mode 100644 index 0000000000..f63d00e135 --- /dev/null +++ b/app/views/admin/dashboard/sincronizar_sigaa.html.erb @@ -0,0 +1,22 @@ + \ No newline at end of file diff --git a/app/views/admin/exportar_csv.csv.erb b/app/views/admin/exportar_csv.csv.erb new file mode 100644 index 0000000000..fae955b369 --- /dev/null +++ b/app/views/admin/exportar_csv.csv.erb @@ -0,0 +1,24 @@ +<% + colunas_dinamicas = ElementoForm.where(formulario_id: @formulario.id) + .order(:ordem) + .pluck(:enunciado) + + cabecalho = ["Usuário da Resposta", "Data de Submissão"] + colunas_dinamicas +-%> +<%= raw CSV.generate_line(cabecalho) -%> +<% @respostas.each do |resposta| -%> +<% + respostas_do_usuario = resposta.resposta_elems.index_by { |re| re.elemento_form.enunciado } + + linha = [ + resposta.usuario&.nome || "Anônimo", + resposta.created_at.strftime("%d/%m/%Y %H:%M") + ] + + colunas_dinamicas.each do |enunciado| + resposta_do_campo = respostas_do_usuario[enunciado] + linha << resposta_do_campo&.texto_resposta + end +-%> +<%= raw CSV.generate_line(linha) -%> +<% end -%> \ No newline at end of file diff --git a/app/views/admin/forms/index.html.erb b/app/views/admin/forms/index.html.erb new file mode 100644 index 0000000000..9b11c62d3b --- /dev/null +++ b/app/views/admin/forms/index.html.erb @@ -0,0 +1,34 @@ +
+

Formulários de Avaliação

+ <%= link_to "Criar Formulário", new_admin_form_path, class: "btn btn--primary" %> +
+ +
+ <% @forms.each do |form| %> +
+
<%= form["title"] %>
+
+ <%= form["semester"] %> · + <%= form["professor"] %> +
+ +
+ <% end %> + + <% if @forms.empty? %> +
+

Nenhum formulário de avaliação criado.

+ <%= link_to "Criar primeiro formulário", new_admin_form_path, class: "btn btn--primary" %> +
+ <% end %> +
\ No newline at end of file diff --git a/app/views/admin/forms/new.html.erb b/app/views/admin/forms/new.html.erb new file mode 100644 index 0000000000..f544272fa4 --- /dev/null +++ b/app/views/admin/forms/new.html.erb @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/app/views/admin/forms/results.html.erb b/app/views/admin/forms/results.html.erb new file mode 100644 index 0000000000..9bde39eedc --- /dev/null +++ b/app/views/admin/forms/results.html.erb @@ -0,0 +1,50 @@ +
+

Resultados - <%= @form["title"] %>

+ <%= link_to "Voltar", admin_forms_path, class: "btn btn--ghost" %> +
+ +
+
+

Resumo

+

Total de respostas: <%= @form["responses"].size %>

+

Semestre: <%= @form["semester"] %>

+

Professor: <%= @form["professor"] %>

+
+ +
+ <% @form["questions"].each do |question| %> +
+

<%= question["title"] %>

+ <% if question["type"] == "radio" %> +
+ <% counts = Hash.new(0) %> + <% @form["responses"].each do |response| %> + <% counts[response["answers"][question["id"]]] += 1 %> + <% end %> + <% question["options"].each do |option| %> +
+ <%= option %>: <%= counts[option] %> votos +
+ <% end %> +
+ <% elsif question["type"] == "text" %> +
+ <% @form["responses"].each do |response| %> + <% if response["answers"][question["id"]].present? %> +
+
<%= response["answers"][question["id"]] %>
+
+ <% end %> + <% end %> +
+ <% end %> +
+ <% end %> + + <% if @form["responses"].empty? %> +
+

Nenhuma resposta recebida ainda.

+
+ <% end %> +
+
\ No newline at end of file diff --git a/app/views/admin/gerenciamento.html.erb b/app/views/admin/gerenciamento.html.erb new file mode 100644 index 0000000000..418e6a5699 --- /dev/null +++ b/app/views/admin/gerenciamento.html.erb @@ -0,0 +1,14 @@ +
+ +

+ Ações de Gerenciamento +

+ + <%= link_to "Importar / Atualizar dados do SIGAA", admin_sincronizar_sigaa_path(@admin), class: "btn-figma" %> + + <%= link_to "Editar Template", admin_templates_path(@admin), class: "btn-figma" %> + + <%= button_to "Resultados", admin_resultados_path, method: :get, class: "btn-figma" %> + + +
diff --git a/app/views/admin/resultados.html.erb b/app/views/admin/resultados.html.erb new file mode 100644 index 0000000000..47ad89b4de --- /dev/null +++ b/app/views/admin/resultados.html.erb @@ -0,0 +1,42 @@ +
+ + <% if @formularios.present? %> +
+ + <% @formularios.each do |formulario| %> +
+ +
+

+ <%= formulario.turma.disciplina.nome %> +

+

+ Turma <%= formulario.turma.numero_da_turma %> +

+

+ <%= formulario.turma.semestre %> - <%= formulario.turma.horario %> +

+
+ +
+

+ <%# Caso a relação no seu model seja diferente, ajuste '.docentes' para o nome correto %> + <%= formulario.turma.docentes.first&.nome || "Professor(a) não alocado(a)" %> +

+ + <%= link_to "Baixar Resultado", baixar_csv_path(id: formulario.id, format: :csv), style: "display: block; text-align: center; background-color: #612F65; color: white; text-decoration: none; padding: 10px 16px; border-radius: 4px; font-weight: bold; font-size: 0.9rem;" %> +
+ +
+ <% end %> + +
+ <% else %> + +
+

Nenhum formulário encontrado para o seu departamento neste semestre.

+
+ + <% end %> + +
\ No newline at end of file diff --git a/app/views/admin/templates/edit.html.erb b/app/views/admin/templates/edit.html.erb new file mode 100644 index 0000000000..1eb6fd1109 --- /dev/null +++ b/app/views/admin/templates/edit.html.erb @@ -0,0 +1,84 @@ + + + \ No newline at end of file diff --git a/app/views/admin/templates/index.html.erb b/app/views/admin/templates/index.html.erb new file mode 100644 index 0000000000..bc985b17b2 --- /dev/null +++ b/app/views/admin/templates/index.html.erb @@ -0,0 +1,29 @@ +
+

Templates de Avaliação

+ <%= link_to "Criar Template", new_admin_template_path, class: "btn btn--primary" %> +
+ +
+ <% @templates.each do |template| %> +
+
<%= template["title"] %>
+
<%= template["semester"] %>
+
<%= template["questions"].size %> perguntas
+ +
+ <% end %> + + <% if @templates.empty? %> +
+

Nenhum template criado ainda.

+ <%= link_to "Criar primeiro template", new_admin_template_path, class: "btn btn--primary" %> +
+ <% end %> + + <%= link_to new_admin_template_path, class: "action-card" do %> + + + <% end %> +
\ No newline at end of file diff --git a/app/views/admin/templates/new.html.erb b/app/views/admin/templates/new.html.erb new file mode 100644 index 0000000000..2a033281a4 --- /dev/null +++ b/app/views/admin/templates/new.html.erb @@ -0,0 +1,84 @@ + + + \ No newline at end of file diff --git a/app/views/campo_forms/_campo_form.html.erb b/app/views/campo_forms/_campo_form.html.erb new file mode 100644 index 0000000000..017c946779 --- /dev/null +++ b/app/views/campo_forms/_campo_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= campo_form.ordem %> +
+ +
+ Enunciado: + <%= campo_form.enunciado %> +
+ +
+ Elemento form: + <%= campo_form.elemento_form_id %> +
+ +
diff --git a/app/views/campo_forms/_campo_form.json.jbuilder b/app/views/campo_forms/_campo_form.json.jbuilder new file mode 100644 index 0000000000..8c75eb97e0 --- /dev/null +++ b/app/views/campo_forms/_campo_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! campo_form, :id, :ordem, :enunciado, :elemento_form_id, :created_at, :updated_at +json.url campo_form_url(campo_form, format: :json) diff --git a/app/views/campo_forms/_form.html.erb b/app/views/campo_forms/_form.html.erb new file mode 100644 index 0000000000..a425f8b8fb --- /dev/null +++ b/app/views/campo_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: campo_form) do |form| %> + <% if campo_form.errors.any? %> +
+

<%= pluralize(campo_form.errors.count, "error") %> prohibited this campo_form from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :elemento_form_id, style: "display: block" %> + <%= form.text_field :elemento_form_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/campo_forms/edit.html.erb b/app/views/campo_forms/edit.html.erb new file mode 100644 index 0000000000..6fcbe94956 --- /dev/null +++ b/app/views/campo_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing campo form" %> + +

Editing campo form

+ +<%= render "form", campo_form: @campo_form %> + +
+ +
+ <%= link_to "Show this campo form", @campo_form %> | + <%= link_to "Back to campo forms", campo_forms_path %> +
diff --git a/app/views/campo_forms/index.html.erb b/app/views/campo_forms/index.html.erb new file mode 100644 index 0000000000..8daeea2454 --- /dev/null +++ b/app/views/campo_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Campo forms" %> + +

Campo forms

+ +
+ <% @campo_forms.each do |campo_form| %> + <%= render campo_form %> +

+ <%= link_to "Show this campo form", campo_form %> +

+ <% end %> +
+ +<%= link_to "New campo form", new_campo_form_path %> diff --git a/app/views/campo_forms/index.json.jbuilder b/app/views/campo_forms/index.json.jbuilder new file mode 100644 index 0000000000..eb30da75b2 --- /dev/null +++ b/app/views/campo_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @campo_forms, partial: "campo_forms/campo_form", as: :campo_form diff --git a/app/views/campo_forms/new.html.erb b/app/views/campo_forms/new.html.erb new file mode 100644 index 0000000000..7b29b045a6 --- /dev/null +++ b/app/views/campo_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New campo form" %> + +

New campo form

+ +<%= render "form", campo_form: @campo_form %> + +
+ +
+ <%= link_to "Back to campo forms", campo_forms_path %> +
diff --git a/app/views/campo_forms/show.html.erb b/app/views/campo_forms/show.html.erb new file mode 100644 index 0000000000..8e6d73f6e0 --- /dev/null +++ b/app/views/campo_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @campo_form %> + +
+ <%= link_to "Edit this campo form", edit_campo_form_path(@campo_form) %> | + <%= link_to "Back to campo forms", campo_forms_path %> + + <%= button_to "Destroy this campo form", @campo_form, method: :delete %> +
diff --git a/app/views/campo_forms/show.json.jbuilder b/app/views/campo_forms/show.json.jbuilder new file mode 100644 index 0000000000..08aeeb5981 --- /dev/null +++ b/app/views/campo_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "campo_forms/campo_form", campo_form: @campo_form diff --git a/app/views/campos/_campo.html.erb b/app/views/campos/_campo.html.erb new file mode 100644 index 0000000000..16889ffbca --- /dev/null +++ b/app/views/campos/_campo.html.erb @@ -0,0 +1,22 @@ +
+
+ Ordem: + <%= campo.ordem %> +
+ +
+ Enunciado: + <%= campo.enunciado %> +
+ +
+ Tipo elemento: + <%= campo.tipo_elemento %> +
+ +
+ Elemento: + <%= campo.elemento_id %> +
+ +
diff --git a/app/views/campos/_campo.json.jbuilder b/app/views/campos/_campo.json.jbuilder new file mode 100644 index 0000000000..91c37792b6 --- /dev/null +++ b/app/views/campos/_campo.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! campo, :id, :ordem, :enunciado, :tipo_elemento, :elemento_id, :created_at, :updated_at +json.url campo_url(campo, format: :json) diff --git a/app/views/campos/_form.html.erb b/app/views/campos/_form.html.erb new file mode 100644 index 0000000000..d240daebc8 --- /dev/null +++ b/app/views/campos/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: campo) do |form| %> + <% if campo.errors.any? %> +
+

<%= pluralize(campo.errors.count, "error") %> prohibited this campo from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :tipo_elemento, style: "display: block" %> + <%= form.text_field :tipo_elemento %> +
+ +
+ <%= form.label :elemento_id, style: "display: block" %> + <%= form.text_field :elemento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/campos/edit.html.erb b/app/views/campos/edit.html.erb new file mode 100644 index 0000000000..f7bf25cf92 --- /dev/null +++ b/app/views/campos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing campo" %> + +

Editing campo

+ +<%= render "form", campo: @campo %> + +
+ +
+ <%= link_to "Show this campo", @campo %> | + <%= link_to "Back to campos", campos_path %> +
diff --git a/app/views/campos/index.html.erb b/app/views/campos/index.html.erb new file mode 100644 index 0000000000..d3f9dd8b6b --- /dev/null +++ b/app/views/campos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Campos" %> + +

Campos

+ +
+ <% @campos.each do |campo| %> + <%= render campo %> +

+ <%= link_to "Show this campo", campo %> +

+ <% end %> +
+ +<%= link_to "New campo", new_campo_path %> diff --git a/app/views/campos/index.json.jbuilder b/app/views/campos/index.json.jbuilder new file mode 100644 index 0000000000..3c0e743402 --- /dev/null +++ b/app/views/campos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @campos, partial: "campos/campo", as: :campo diff --git a/app/views/campos/new.html.erb b/app/views/campos/new.html.erb new file mode 100644 index 0000000000..96fe844c6e --- /dev/null +++ b/app/views/campos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New campo" %> + +

New campo

+ +<%= render "form", campo: @campo %> + +
+ +
+ <%= link_to "Back to campos", campos_path %> +
diff --git a/app/views/campos/show.html.erb b/app/views/campos/show.html.erb new file mode 100644 index 0000000000..3535330c82 --- /dev/null +++ b/app/views/campos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @campo %> + +
+ <%= link_to "Edit this campo", edit_campo_path(@campo) %> | + <%= link_to "Back to campos", campos_path %> + + <%= button_to "Destroy this campo", @campo, method: :delete %> +
diff --git a/app/views/campos/show.json.jbuilder b/app/views/campos/show.json.jbuilder new file mode 100644 index 0000000000..bdb6307753 --- /dev/null +++ b/app/views/campos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "campos/campo", campo: @campo diff --git a/app/views/cursos/_curso.html.erb b/app/views/cursos/_curso.html.erb new file mode 100644 index 0000000000..4542c6c387 --- /dev/null +++ b/app/views/cursos/_curso.html.erb @@ -0,0 +1,17 @@ +
+
+ Codigo: + <%= curso.codigo %> +
+ +
+ Nome: + <%= curso.nome %> +
+ +
+ Departamento: + <%= curso.departamento_id %> +
+ +
diff --git a/app/views/cursos/_curso.json.jbuilder b/app/views/cursos/_curso.json.jbuilder new file mode 100644 index 0000000000..fc8ea66f22 --- /dev/null +++ b/app/views/cursos/_curso.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! curso, :id, :codigo, :nome, :departamento_id, :created_at, :updated_at +json.url curso_url(curso, format: :json) diff --git a/app/views/cursos/_form.html.erb b/app/views/cursos/_form.html.erb new file mode 100644 index 0000000000..8e110c66e9 --- /dev/null +++ b/app/views/cursos/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: curso) do |form| %> + <% if curso.errors.any? %> +
+

<%= pluralize(curso.errors.count, "error") %> prohibited this curso from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :departamento_id, style: "display: block" %> + <%= form.text_field :departamento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/cursos/edit.html.erb b/app/views/cursos/edit.html.erb new file mode 100644 index 0000000000..146b27780b --- /dev/null +++ b/app/views/cursos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing curso" %> + +

Editing curso

+ +<%= render "form", curso: @curso %> + +
+ +
+ <%= link_to "Show this curso", @curso %> | + <%= link_to "Back to cursos", cursos_path %> +
diff --git a/app/views/cursos/index.html.erb b/app/views/cursos/index.html.erb new file mode 100644 index 0000000000..24626172a0 --- /dev/null +++ b/app/views/cursos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Cursos" %> + +

Cursos

+ +
+ <% @cursos.each do |curso| %> + <%= render curso %> +

+ <%= link_to "Show this curso", curso %> +

+ <% end %> +
+ +<%= link_to "New curso", new_curso_path %> diff --git a/app/views/cursos/index.json.jbuilder b/app/views/cursos/index.json.jbuilder new file mode 100644 index 0000000000..2e39c23019 --- /dev/null +++ b/app/views/cursos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @cursos, partial: "cursos/curso", as: :curso diff --git a/app/views/cursos/new.html.erb b/app/views/cursos/new.html.erb new file mode 100644 index 0000000000..f4f7bec9ba --- /dev/null +++ b/app/views/cursos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New curso" %> + +

New curso

+ +<%= render "form", curso: @curso %> + +
+ +
+ <%= link_to "Back to cursos", cursos_path %> +
diff --git a/app/views/cursos/show.html.erb b/app/views/cursos/show.html.erb new file mode 100644 index 0000000000..3f0601c157 --- /dev/null +++ b/app/views/cursos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @curso %> + +
+ <%= link_to "Edit this curso", edit_curso_path(@curso) %> | + <%= link_to "Back to cursos", cursos_path %> + + <%= button_to "Destroy this curso", @curso, method: :delete %> +
diff --git a/app/views/cursos/show.json.jbuilder b/app/views/cursos/show.json.jbuilder new file mode 100644 index 0000000000..74b378ecab --- /dev/null +++ b/app/views/cursos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "cursos/curso", curso: @curso diff --git a/app/views/definicao_senhas/edit.html.erb b/app/views/definicao_senhas/edit.html.erb new file mode 100644 index 0000000000..db28bdd159 --- /dev/null +++ b/app/views/definicao_senhas/edit.html.erb @@ -0,0 +1,17 @@ +

Definição de senha

+ +<%= form_with url: definicao_senha_path(token: params[:token]), method: :patch do %> +
+ <%= label_tag :senha, "Nova senha" %> + <%= password_field_tag :senha %> +
+ +
+ <%= label_tag :senha_confirmation, "Confirmar senha" %> + <%= password_field_tag :senha_confirmation %> +
+ +
+ <%= submit_tag "Definir senha" %> +
+<% end %> diff --git a/app/views/departamentos/_departamento.html.erb b/app/views/departamentos/_departamento.html.erb new file mode 100644 index 0000000000..b4e3907c9a --- /dev/null +++ b/app/views/departamentos/_departamento.html.erb @@ -0,0 +1,12 @@ +
+
+ Codigo: + <%= departamento.codigo %> +
+ +
+ Nome: + <%= departamento.nome %> +
+ +
diff --git a/app/views/departamentos/_departamento.json.jbuilder b/app/views/departamentos/_departamento.json.jbuilder new file mode 100644 index 0000000000..2145ba20c5 --- /dev/null +++ b/app/views/departamentos/_departamento.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! departamento, :id, :codigo, :nome, :created_at, :updated_at +json.url departamento_url(departamento, format: :json) diff --git a/app/views/departamentos/_form.html.erb b/app/views/departamentos/_form.html.erb new file mode 100644 index 0000000000..a8ed55c8f4 --- /dev/null +++ b/app/views/departamentos/_form.html.erb @@ -0,0 +1,27 @@ +<%= form_with(model: departamento) do |form| %> + <% if departamento.errors.any? %> +
+

<%= pluralize(departamento.errors.count, "error") %> prohibited this departamento from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/departamentos/edit.html.erb b/app/views/departamentos/edit.html.erb new file mode 100644 index 0000000000..f63ef9cac0 --- /dev/null +++ b/app/views/departamentos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing departamento" %> + +

Editing departamento

+ +<%= render "form", departamento: @departamento %> + +
+ +
+ <%= link_to "Show this departamento", @departamento %> | + <%= link_to "Back to departamentos", departamentos_path %> +
diff --git a/app/views/departamentos/index.html.erb b/app/views/departamentos/index.html.erb new file mode 100644 index 0000000000..a05d2b04fa --- /dev/null +++ b/app/views/departamentos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Departamentos" %> + +

Departamentos

+ +
+ <% @departamentos.each do |departamento| %> + <%= render departamento %> +

+ <%= link_to "Show this departamento", departamento %> +

+ <% end %> +
+ +<%= link_to "New departamento", new_departamento_path %> diff --git a/app/views/departamentos/index.json.jbuilder b/app/views/departamentos/index.json.jbuilder new file mode 100644 index 0000000000..030ab748d1 --- /dev/null +++ b/app/views/departamentos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @departamentos, partial: "departamentos/departamento", as: :departamento diff --git a/app/views/departamentos/new.html.erb b/app/views/departamentos/new.html.erb new file mode 100644 index 0000000000..76eefa1cfb --- /dev/null +++ b/app/views/departamentos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New departamento" %> + +

New departamento

+ +<%= render "form", departamento: @departamento %> + +
+ +
+ <%= link_to "Back to departamentos", departamentos_path %> +
diff --git a/app/views/departamentos/show.html.erb b/app/views/departamentos/show.html.erb new file mode 100644 index 0000000000..2957799d46 --- /dev/null +++ b/app/views/departamentos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @departamento %> + +
+ <%= link_to "Edit this departamento", edit_departamento_path(@departamento) %> | + <%= link_to "Back to departamentos", departamentos_path %> + + <%= button_to "Destroy this departamento", @departamento, method: :delete %> +
diff --git a/app/views/departamentos/show.json.jbuilder b/app/views/departamentos/show.json.jbuilder new file mode 100644 index 0000000000..13c4a70c0c --- /dev/null +++ b/app/views/departamentos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "departamentos/departamento", departamento: @departamento diff --git a/app/views/discentes/_discente.html.erb b/app/views/discentes/_discente.html.erb new file mode 100644 index 0000000000..6d800585cc --- /dev/null +++ b/app/views/discentes/_discente.html.erb @@ -0,0 +1,27 @@ +
+
+ Matricula: + <%= discente.matricula %> +
+ +
+ Email: + <%= discente.email %> +
+ +
+ Nome: + <%= discente.nome %> +
+ +
+ Formacao: + <%= discente.formacao %> +
+ +
+ Curso: + <%= discente.curso_id %> +
+ +
diff --git a/app/views/discentes/_discente.json.jbuilder b/app/views/discentes/_discente.json.jbuilder new file mode 100644 index 0000000000..1451775555 --- /dev/null +++ b/app/views/discentes/_discente.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! discente, :id, :matricula, :email, :nome, :formacao, :curso_id, :created_at, :updated_at +json.url discente_url(discente, format: :json) diff --git a/app/views/discentes/_form.html.erb b/app/views/discentes/_form.html.erb new file mode 100644 index 0000000000..1508351bb7 --- /dev/null +++ b/app/views/discentes/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: discente) do |form| %> + <% if discente.errors.any? %> +
+

<%= pluralize(discente.errors.count, "error") %> prohibited this discente from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.label :curso_id, style: "display: block" %> + <%= form.text_field :curso_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/discentes/edit.html.erb b/app/views/discentes/edit.html.erb new file mode 100644 index 0000000000..b406df6523 --- /dev/null +++ b/app/views/discentes/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing discente" %> + +

Editing discente

+ +<%= render "form", discente: @discente %> + +
+ +
+ <%= link_to "Show this discente", @discente %> | + <%= link_to "Back to discentes", discentes_path %> +
diff --git a/app/views/discentes/index.html.erb b/app/views/discentes/index.html.erb new file mode 100644 index 0000000000..55626169e5 --- /dev/null +++ b/app/views/discentes/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Discentes" %> + +

Discentes

+ +
+ <% @discentes.each do |discente| %> + <%= render discente %> +

+ <%= link_to "Show this discente", discente %> +

+ <% end %> +
+ +<%= link_to "New discente", new_discente_path %> diff --git a/app/views/discentes/index.json.jbuilder b/app/views/discentes/index.json.jbuilder new file mode 100644 index 0000000000..80c25ce894 --- /dev/null +++ b/app/views/discentes/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @discentes, partial: "discentes/discente", as: :discente diff --git a/app/views/discentes/new.html.erb b/app/views/discentes/new.html.erb new file mode 100644 index 0000000000..964c1192ba --- /dev/null +++ b/app/views/discentes/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New discente" %> + +

New discente

+ +<%= render "form", discente: @discente %> + +
+ +
+ <%= link_to "Back to discentes", discentes_path %> +
diff --git a/app/views/discentes/show.html.erb b/app/views/discentes/show.html.erb new file mode 100644 index 0000000000..253165e73e --- /dev/null +++ b/app/views/discentes/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @discente %> + +
+ <%= link_to "Edit this discente", edit_discente_path(@discente) %> | + <%= link_to "Back to discentes", discentes_path %> + + <%= button_to "Destroy this discente", @discente, method: :delete %> +
diff --git a/app/views/discentes/show.json.jbuilder b/app/views/discentes/show.json.jbuilder new file mode 100644 index 0000000000..0d3ad84a23 --- /dev/null +++ b/app/views/discentes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "discentes/discente", discente: @discente diff --git a/app/views/disciplinas/_disciplina.html.erb b/app/views/disciplinas/_disciplina.html.erb new file mode 100644 index 0000000000..eece272568 --- /dev/null +++ b/app/views/disciplinas/_disciplina.html.erb @@ -0,0 +1,17 @@ +
+
+ Codigo: + <%= disciplina.codigo %> +
+ +
+ Nome: + <%= disciplina.nome %> +
+ +
+ Departamento: + <%= disciplina.departamento_id %> +
+ +
diff --git a/app/views/disciplinas/_disciplina.json.jbuilder b/app/views/disciplinas/_disciplina.json.jbuilder new file mode 100644 index 0000000000..c7fc54340e --- /dev/null +++ b/app/views/disciplinas/_disciplina.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! disciplina, :id, :codigo, :nome, :departamento_id, :created_at, :updated_at +json.url disciplina_url(disciplina, format: :json) diff --git a/app/views/disciplinas/_form.html.erb b/app/views/disciplinas/_form.html.erb new file mode 100644 index 0000000000..373da8e92a --- /dev/null +++ b/app/views/disciplinas/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: disciplina) do |form| %> + <% if disciplina.errors.any? %> +
+

<%= pluralize(disciplina.errors.count, "error") %> prohibited this disciplina from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :codigo, style: "display: block" %> + <%= form.text_field :codigo %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :departamento_id, style: "display: block" %> + <%= form.text_field :departamento_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/disciplinas/edit.html.erb b/app/views/disciplinas/edit.html.erb new file mode 100644 index 0000000000..d43c76ac3f --- /dev/null +++ b/app/views/disciplinas/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing disciplina" %> + +

Editing disciplina

+ +<%= render "form", disciplina: @disciplina %> + +
+ +
+ <%= link_to "Show this disciplina", @disciplina %> | + <%= link_to "Back to disciplinas", disciplinas_path %> +
diff --git a/app/views/disciplinas/index.html.erb b/app/views/disciplinas/index.html.erb new file mode 100644 index 0000000000..f2806e550c --- /dev/null +++ b/app/views/disciplinas/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Disciplinas" %> + +

Disciplinas

+ +
+ <% @disciplinas.each do |disciplina| %> + <%= render disciplina %> +

+ <%= link_to "Show this disciplina", disciplina %> +

+ <% end %> +
+ +<%= link_to "New disciplina", new_disciplina_path %> diff --git a/app/views/disciplinas/index.json.jbuilder b/app/views/disciplinas/index.json.jbuilder new file mode 100644 index 0000000000..f7dfbb1351 --- /dev/null +++ b/app/views/disciplinas/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @disciplinas, partial: "disciplinas/disciplina", as: :disciplina diff --git a/app/views/disciplinas/new.html.erb b/app/views/disciplinas/new.html.erb new file mode 100644 index 0000000000..749a8f81d4 --- /dev/null +++ b/app/views/disciplinas/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New disciplina" %> + +

New disciplina

+ +<%= render "form", disciplina: @disciplina %> + +
+ +
+ <%= link_to "Back to disciplinas", disciplinas_path %> +
diff --git a/app/views/disciplinas/show.html.erb b/app/views/disciplinas/show.html.erb new file mode 100644 index 0000000000..53498063d9 --- /dev/null +++ b/app/views/disciplinas/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @disciplina %> + +
+ <%= link_to "Edit this disciplina", edit_disciplina_path(@disciplina) %> | + <%= link_to "Back to disciplinas", disciplinas_path %> + + <%= button_to "Destroy this disciplina", @disciplina, method: :delete %> +
diff --git a/app/views/disciplinas/show.json.jbuilder b/app/views/disciplinas/show.json.jbuilder new file mode 100644 index 0000000000..81900042ae --- /dev/null +++ b/app/views/disciplinas/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "disciplinas/disciplina", disciplina: @disciplina diff --git a/app/views/docentes/_docente.html.erb b/app/views/docentes/_docente.html.erb new file mode 100644 index 0000000000..1aebfe62bf --- /dev/null +++ b/app/views/docentes/_docente.html.erb @@ -0,0 +1,22 @@ +
+
+ Matricula: + <%= docente.matricula %> +
+ +
+ Email: + <%= docente.email %> +
+ +
+ Nome: + <%= docente.nome %> +
+ +
+ Formacao: + <%= docente.formacao %> +
+ +
diff --git a/app/views/docentes/_docente.json.jbuilder b/app/views/docentes/_docente.json.jbuilder new file mode 100644 index 0000000000..6d10e76c27 --- /dev/null +++ b/app/views/docentes/_docente.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! docente, :id, :matricula, :email, :nome, :formacao, :created_at, :updated_at +json.url docente_url(docente, format: :json) diff --git a/app/views/docentes/_form.html.erb b/app/views/docentes/_form.html.erb new file mode 100644 index 0000000000..59d2257579 --- /dev/null +++ b/app/views/docentes/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: docente) do |form| %> + <% if docente.errors.any? %> +
+

<%= pluralize(docente.errors.count, "error") %> prohibited this docente from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/docentes/edit.html.erb b/app/views/docentes/edit.html.erb new file mode 100644 index 0000000000..f943000a91 --- /dev/null +++ b/app/views/docentes/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing docente" %> + +

Editing docente

+ +<%= render "form", docente: @docente %> + +
+ +
+ <%= link_to "Show this docente", @docente %> | + <%= link_to "Back to docentes", docentes_path %> +
diff --git a/app/views/docentes/index.html.erb b/app/views/docentes/index.html.erb new file mode 100644 index 0000000000..87242c4310 --- /dev/null +++ b/app/views/docentes/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Docentes" %> + +

Docentes

+ +
+ <% @docentes.each do |docente| %> + <%= render docente %> +

+ <%= link_to "Show this docente", docente %> +

+ <% end %> +
+ +<%= link_to "New docente", new_docente_path %> diff --git a/app/views/docentes/index.json.jbuilder b/app/views/docentes/index.json.jbuilder new file mode 100644 index 0000000000..9fa1138d65 --- /dev/null +++ b/app/views/docentes/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @docentes, partial: "docentes/docente", as: :docente diff --git a/app/views/docentes/new.html.erb b/app/views/docentes/new.html.erb new file mode 100644 index 0000000000..963e827ea2 --- /dev/null +++ b/app/views/docentes/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New docente" %> + +

New docente

+ +<%= render "form", docente: @docente %> + +
+ +
+ <%= link_to "Back to docentes", docentes_path %> +
diff --git a/app/views/docentes/show.html.erb b/app/views/docentes/show.html.erb new file mode 100644 index 0000000000..2cae716ac2 --- /dev/null +++ b/app/views/docentes/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @docente %> + +
+ <%= link_to "Edit this docente", edit_docente_path(@docente) %> | + <%= link_to "Back to docentes", docentes_path %> + + <%= button_to "Destroy this docente", @docente, method: :delete %> +
diff --git a/app/views/docentes/show.json.jbuilder b/app/views/docentes/show.json.jbuilder new file mode 100644 index 0000000000..52216e7d59 --- /dev/null +++ b/app/views/docentes/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "docentes/docente", docente: @docente diff --git a/app/views/elemento_forms/_elemento_form.html.erb b/app/views/elemento_forms/_elemento_form.html.erb new file mode 100644 index 0000000000..c9c8ff75dd --- /dev/null +++ b/app/views/elemento_forms/_elemento_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= elemento_form.ordem %> +
+ +
+ Enunciado: + <%= elemento_form.enunciado %> +
+ +
+ Formulario: + <%= elemento_form.formulario_id %> +
+ +
diff --git a/app/views/elemento_forms/_elemento_form.json.jbuilder b/app/views/elemento_forms/_elemento_form.json.jbuilder new file mode 100644 index 0000000000..c8c9c3c1dd --- /dev/null +++ b/app/views/elemento_forms/_elemento_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! elemento_form, :id, :ordem, :enunciado, :formulario_id, :created_at, :updated_at +json.url elemento_form_url(elemento_form, format: :json) diff --git a/app/views/elemento_forms/_form.html.erb b/app/views/elemento_forms/_form.html.erb new file mode 100644 index 0000000000..e82793e837 --- /dev/null +++ b/app/views/elemento_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: elemento_form) do |form| %> + <% if elemento_form.errors.any? %> +
+

<%= pluralize(elemento_form.errors.count, "error") %> prohibited this elemento_form from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :formulario_id, style: "display: block" %> + <%= form.text_field :formulario_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/elemento_forms/edit.html.erb b/app/views/elemento_forms/edit.html.erb new file mode 100644 index 0000000000..a40b53f636 --- /dev/null +++ b/app/views/elemento_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing elemento form" %> + +

Editing elemento form

+ +<%= render "form", elemento_form: @elemento_form %> + +
+ +
+ <%= link_to "Show this elemento form", @elemento_form %> | + <%= link_to "Back to elemento forms", elemento_forms_path %> +
diff --git a/app/views/elemento_forms/index.html.erb b/app/views/elemento_forms/index.html.erb new file mode 100644 index 0000000000..ee86c1863e --- /dev/null +++ b/app/views/elemento_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Elemento forms" %> + +

Elemento forms

+ +
+ <% @elemento_forms.each do |elemento_form| %> + <%= render elemento_form %> +

+ <%= link_to "Show this elemento form", elemento_form %> +

+ <% end %> +
+ +<%= link_to "New elemento form", new_elemento_form_path %> diff --git a/app/views/elemento_forms/index.json.jbuilder b/app/views/elemento_forms/index.json.jbuilder new file mode 100644 index 0000000000..d92ed08923 --- /dev/null +++ b/app/views/elemento_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @elemento_forms, partial: "elemento_forms/elemento_form", as: :elemento_form diff --git a/app/views/elemento_forms/new.html.erb b/app/views/elemento_forms/new.html.erb new file mode 100644 index 0000000000..1802adb7fc --- /dev/null +++ b/app/views/elemento_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New elemento form" %> + +

New elemento form

+ +<%= render "form", elemento_form: @elemento_form %> + +
+ +
+ <%= link_to "Back to elemento forms", elemento_forms_path %> +
diff --git a/app/views/elemento_forms/show.html.erb b/app/views/elemento_forms/show.html.erb new file mode 100644 index 0000000000..216c0abdbf --- /dev/null +++ b/app/views/elemento_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @elemento_form %> + +
+ <%= link_to "Edit this elemento form", edit_elemento_form_path(@elemento_form) %> | + <%= link_to "Back to elemento forms", elemento_forms_path %> + + <%= button_to "Destroy this elemento form", @elemento_form, method: :delete %> +
diff --git a/app/views/elemento_forms/show.json.jbuilder b/app/views/elemento_forms/show.json.jbuilder new file mode 100644 index 0000000000..f73a125a23 --- /dev/null +++ b/app/views/elemento_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "elemento_forms/elemento_form", elemento_form: @elemento_form diff --git a/app/views/elementos/_elemento.html.erb b/app/views/elementos/_elemento.html.erb new file mode 100644 index 0000000000..2fba356080 --- /dev/null +++ b/app/views/elementos/_elemento.html.erb @@ -0,0 +1,17 @@ +
+
+ Ordem: + <%= elemento.ordem %> +
+ +
+ Enunciado: + <%= elemento.enunciado %> +
+ +
+ Template: + <%= elemento.template_id %> +
+ +
diff --git a/app/views/elementos/_elemento.json.jbuilder b/app/views/elementos/_elemento.json.jbuilder new file mode 100644 index 0000000000..ab132a3548 --- /dev/null +++ b/app/views/elementos/_elemento.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! elemento, :id, :ordem, :enunciado, :template_id, :created_at, :updated_at +json.url elemento_url(elemento, format: :json) diff --git a/app/views/elementos/_form.html.erb b/app/views/elementos/_form.html.erb new file mode 100644 index 0000000000..e7f9b64d4c --- /dev/null +++ b/app/views/elementos/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: elemento) do |form| %> + <% if elemento.errors.any? %> +
+

<%= pluralize(elemento.errors.count, "error") %> prohibited this elemento from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :ordem, style: "display: block" %> + <%= form.number_field :ordem %> +
+ +
+ <%= form.label :enunciado, style: "display: block" %> + <%= form.text_field :enunciado %> +
+ +
+ <%= form.label :template_id, style: "display: block" %> + <%= form.text_field :template_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/elementos/edit.html.erb b/app/views/elementos/edit.html.erb new file mode 100644 index 0000000000..e8021663c8 --- /dev/null +++ b/app/views/elementos/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing elemento" %> + +

Editing elemento

+ +<%= render "form", elemento: @elemento %> + +
+ +
+ <%= link_to "Show this elemento", @elemento %> | + <%= link_to "Back to elementos", elementos_path %> +
diff --git a/app/views/elementos/index.html.erb b/app/views/elementos/index.html.erb new file mode 100644 index 0000000000..e3edba25e0 --- /dev/null +++ b/app/views/elementos/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Elementos" %> + +

Elementos

+ +
+ <% @elementos.each do |elemento| %> + <%= render elemento %> +

+ <%= link_to "Show this elemento", elemento %> +

+ <% end %> +
+ +<%= link_to "New elemento", new_elemento_path %> diff --git a/app/views/elementos/index.json.jbuilder b/app/views/elementos/index.json.jbuilder new file mode 100644 index 0000000000..bbf28cc646 --- /dev/null +++ b/app/views/elementos/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @elementos, partial: "elementos/elemento", as: :elemento diff --git a/app/views/elementos/new.html.erb b/app/views/elementos/new.html.erb new file mode 100644 index 0000000000..dc3997b102 --- /dev/null +++ b/app/views/elementos/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New elemento" %> + +

New elemento

+ +<%= render "form", elemento: @elemento %> + +
+ +
+ <%= link_to "Back to elementos", elementos_path %> +
diff --git a/app/views/elementos/show.html.erb b/app/views/elementos/show.html.erb new file mode 100644 index 0000000000..e8d76a29af --- /dev/null +++ b/app/views/elementos/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @elemento %> + +
+ <%= link_to "Edit this elemento", edit_elemento_path(@elemento) %> | + <%= link_to "Back to elementos", elementos_path %> + + <%= button_to "Destroy this elemento", @elemento, method: :delete %> +
diff --git a/app/views/elementos/show.json.jbuilder b/app/views/elementos/show.json.jbuilder new file mode 100644 index 0000000000..a39f969950 --- /dev/null +++ b/app/views/elementos/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "elementos/elemento", elemento: @elemento diff --git a/app/views/forms/index.html.erb b/app/views/forms/index.html.erb new file mode 100644 index 0000000000..2c87305c82 --- /dev/null +++ b/app/views/forms/index.html.erb @@ -0,0 +1,34 @@ +
+ + +
+
+

Avaliações Pendentes

+
U
+ <%= button_to "Sair", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ <% if @forms.empty? %> +
+

Nenhuma avaliação pendente no momento.

+
+ <% else %> +
+ <% @forms.each do |form| %> + <%= link_to form_path(form["id"]), class: "card" do %> +
<%= form["title"] %>
+
<%= form["semester"] %>
+
<%= form["professor"] %>
+ + <% end %> + <% end %> +
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/forms/show.html.erb b/app/views/forms/show.html.erb new file mode 100644 index 0000000000..48f130d636 --- /dev/null +++ b/app/views/forms/show.html.erb @@ -0,0 +1,48 @@ +
+ + +
+
+ +

Avaliação - <%= @form["title"] %> - <%= @form["semester"] %>

+
+
U
+ <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ +
+
+
\ No newline at end of file diff --git a/app/views/formularios/_form.html.erb b/app/views/formularios/_form.html.erb new file mode 100644 index 0000000000..ddbf9658b6 --- /dev/null +++ b/app/views/formularios/_form.html.erb @@ -0,0 +1,22 @@ +<%= form_with(model: formulario) do |form| %> + <% if formulario.errors.any? %> +
+

<%= pluralize(formulario.errors.count, "error") %> prohibited this formulario from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :turma_id, style: "display: block" %> + <%= form.text_field :turma_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/formularios/_formulario.html.erb b/app/views/formularios/_formulario.html.erb new file mode 100644 index 0000000000..18470d4252 --- /dev/null +++ b/app/views/formularios/_formulario.html.erb @@ -0,0 +1,7 @@ +
+
+ Turma: + <%= formulario.turma_id %> +
+ +
diff --git a/app/views/formularios/_formulario.json.jbuilder b/app/views/formularios/_formulario.json.jbuilder new file mode 100644 index 0000000000..70529ec0c5 --- /dev/null +++ b/app/views/formularios/_formulario.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! formulario, :id, :turma_id, :created_at, :updated_at +json.url formulario_url(formulario, format: :json) diff --git a/app/views/formularios/edit.html.erb b/app/views/formularios/edit.html.erb new file mode 100644 index 0000000000..2fb833aa29 --- /dev/null +++ b/app/views/formularios/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing formulario" %> + +

Editing formulario

+ +<%= render "form", formulario: @formulario %> + +
+ +
+ <%= link_to "Show this formulario", @formulario %> | + <%= link_to "Back to formularios", formularios_path %> +
diff --git a/app/views/formularios/index.html.erb b/app/views/formularios/index.html.erb new file mode 100644 index 0000000000..99df9d53e3 --- /dev/null +++ b/app/views/formularios/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Formularios" %> + +

Formularios

+ +
+ <% @formularios.each do |formulario| %> + <%= render formulario %> +

+ <%= link_to "Show this formulario", formulario %> +

+ <% end %> +
+ +<%= link_to "New formulario", new_formulario_path %> diff --git a/app/views/formularios/index.json.jbuilder b/app/views/formularios/index.json.jbuilder new file mode 100644 index 0000000000..70770973a8 --- /dev/null +++ b/app/views/formularios/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @formularios, partial: "formularios/formulario", as: :formulario diff --git a/app/views/formularios/new.html.erb b/app/views/formularios/new.html.erb new file mode 100644 index 0000000000..0dbdfdbd5c --- /dev/null +++ b/app/views/formularios/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New formulario" %> + +

New formulario

+ +<%= render "form", formulario: @formulario %> + +
+ +
+ <%= link_to "Back to formularios", formularios_path %> +
diff --git a/app/views/formularios/show.html.erb b/app/views/formularios/show.html.erb new file mode 100644 index 0000000000..24709ac66b --- /dev/null +++ b/app/views/formularios/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @formulario %> + +
+ <%= link_to "Edit this formulario", edit_formulario_path(@formulario) %> | + <%= link_to "Back to formularios", formularios_path %> + + <%= button_to "Destroy this formulario", @formulario, method: :delete %> +
diff --git a/app/views/formularios/show.json.jbuilder b/app/views/formularios/show.json.jbuilder new file mode 100644 index 0000000000..476f64d624 --- /dev/null +++ b/app/views/formularios/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "formularios/formulario", formulario: @formulario diff --git a/app/views/home/index.html.erb b/app/views/home/index.html.erb new file mode 100644 index 0000000000..51af7b55ad --- /dev/null +++ b/app/views/home/index.html.erb @@ -0,0 +1,38 @@ +
+ + +
+
+

Avaliações

+
+
U
+ <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--ghost" %> +
+ +
+ <% if @forms.present? %> +
+ <% @forms.each do |form| %> + <%= link_to form_path(form["id"]), class: "card" do %> +
<%= form["title"] %>
+
<%= form["semester"] %>
+
<%= form["professor"] %>
+ + <% end %> + <% end %> +
+ <% else %> +
+

Nenhuma avaliação disponível no momento.

+
+ <% end %> +
+
+
\ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb new file mode 100644 index 0000000000..76b583b824 --- /dev/null +++ b/app/views/layouts/application.html.erb @@ -0,0 +1,33 @@ + + + + <%= content_for(:title) || "Camaar" %> + + + + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= yield :head %> + + <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %> + <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %> + + + + + + <%# Includes all stylesheet files in app/assets/stylesheets %> + <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %> + <%= javascript_importmap_tags %> + + + + <% flash.each do |type, message| %> +
<%= message %>
+ <% end %> + + <%= yield %> + + diff --git a/app/views/layouts/gerenciamento.html.erb b/app/views/layouts/gerenciamento.html.erb new file mode 100644 index 0000000000..9b02dbd0b5 --- /dev/null +++ b/app/views/layouts/gerenciamento.html.erb @@ -0,0 +1,42 @@ + + + + CAMAAR - Gerenciamento + + <%= csrf_meta_tags %> + <%= csp_meta_tag %> + + <%= stylesheet_link_tag "application", "data-turbo-track": "reload" %> + + + +
+ + +
+
+

Admin CAMAAR

+
+
A
+ <%= link_to "Voltar ao Início", inicio_path, class: "btn btn--ghost" %> + <%= button_to "Logout", logout_path, method: :delete, class: "btn btn--danger" %> +
+ +
+ <% flash.each do |type, message| %> +
+
+ <%= message %> +
+
+ <% end %> + <%= yield %> +
+
+
+ + \ No newline at end of file diff --git a/app/views/layouts/mailer.html.erb b/app/views/layouts/mailer.html.erb new file mode 100644 index 0000000000..3aac9002ed --- /dev/null +++ b/app/views/layouts/mailer.html.erb @@ -0,0 +1,13 @@ + + + + + + + + + <%= yield %> + + diff --git a/app/views/layouts/mailer.text.erb b/app/views/layouts/mailer.text.erb new file mode 100644 index 0000000000..37f0bddbd7 --- /dev/null +++ b/app/views/layouts/mailer.text.erb @@ -0,0 +1 @@ +<%= yield %> diff --git a/app/views/pwa/manifest.json.erb b/app/views/pwa/manifest.json.erb new file mode 100644 index 0000000000..fca522bbe4 --- /dev/null +++ b/app/views/pwa/manifest.json.erb @@ -0,0 +1,22 @@ +{ + "name": "Camaar", + "icons": [ + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512" + }, + { + "src": "/icon.png", + "type": "image/png", + "sizes": "512x512", + "purpose": "maskable" + } + ], + "start_url": "/", + "display": "standalone", + "scope": "/", + "description": "Camaar.", + "theme_color": "red", + "background_color": "red" +} diff --git a/app/views/pwa/service-worker.js b/app/views/pwa/service-worker.js new file mode 100644 index 0000000000..b3a13fb7bb --- /dev/null +++ b/app/views/pwa/service-worker.js @@ -0,0 +1,26 @@ +// Add a service worker for processing Web Push notifications: +// +// self.addEventListener("push", async (event) => { +// const { title, options } = await event.data.json() +// event.waitUntil(self.registration.showNotification(title, options)) +// }) +// +// self.addEventListener("notificationclick", function(event) { +// event.notification.close() +// event.waitUntil( +// clients.matchAll({ type: "window" }).then((clientList) => { +// for (let i = 0; i < clientList.length; i++) { +// let client = clientList[i] +// let clientPath = (new URL(client.url)).pathname +// +// if (clientPath == event.notification.data.path && "focus" in client) { +// return client.focus() +// } +// } +// +// if (clients.openWindow) { +// return clients.openWindow(event.notification.data.path) +// } +// }) +// ) +// }) diff --git a/app/views/redefinicao_senhas/edit.html.erb b/app/views/redefinicao_senhas/edit.html.erb new file mode 100644 index 0000000000..e79c4226bb --- /dev/null +++ b/app/views/redefinicao_senhas/edit.html.erb @@ -0,0 +1,17 @@ +

Redefinição de senha

+ +<%= form_with url: redefinicao_senha_path(token: params[:token]), method: :patch do %> +
+ <%= label_tag :senha, "Nova senha" %> + <%= password_field_tag :senha %> +
+ +
+ <%= label_tag :senha_confirmation, "Confirmar senha" %> + <%= password_field_tag :senha_confirmation %> +
+ +
+ <%= submit_tag "Redefinir senha" %> +
+<% end %> diff --git a/app/views/redefinicao_senhas/new.html.erb b/app/views/redefinicao_senhas/new.html.erb new file mode 100644 index 0000000000..e7234e77f1 --- /dev/null +++ b/app/views/redefinicao_senhas/new.html.erb @@ -0,0 +1,19 @@ +
+
+ +

Redefinição de senha

+ + <%= form_with url: redefinir_senha_path do %> + +
+ <%= label_tag :email, "Email" %> + <%= email_field_tag :email %> +
+ + <%= submit_tag "Solicitar redefinição", + class: "btn-submit" %> + + <% end %> + +
+
\ No newline at end of file diff --git a/app/views/resposta_elems/_form.html.erb b/app/views/resposta_elems/_form.html.erb new file mode 100644 index 0000000000..3e09b2d5ee --- /dev/null +++ b/app/views/resposta_elems/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: resposta_elem) do |form| %> + <% if resposta_elem.errors.any? %> +
+

<%= pluralize(resposta_elem.errors.count, "error") %> prohibited this resposta_elem from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :texto_resposta, style: "display: block" %> + <%= form.textarea :texto_resposta %> +
+ +
+ <%= form.label :resposta_form_id, style: "display: block" %> + <%= form.text_field :resposta_form_id %> +
+ +
+ <%= form.label :elemento_form_id, style: "display: block" %> + <%= form.text_field :elemento_form_id %> +
+ +
+ <%= form.label :campo_form_id, style: "display: block" %> + <%= form.text_field :campo_form_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/resposta_elems/_resposta_elem.html.erb b/app/views/resposta_elems/_resposta_elem.html.erb new file mode 100644 index 0000000000..8c745b02ac --- /dev/null +++ b/app/views/resposta_elems/_resposta_elem.html.erb @@ -0,0 +1,22 @@ +
+
+ Texto resposta: + <%= resposta_elem.texto_resposta %> +
+ +
+ Resposta form: + <%= resposta_elem.resposta_form_id %> +
+ +
+ Elemento form: + <%= resposta_elem.elemento_form_id %> +
+ +
+ Campo form: + <%= resposta_elem.campo_form_id %> +
+ +
diff --git a/app/views/resposta_elems/_resposta_elem.json.jbuilder b/app/views/resposta_elems/_resposta_elem.json.jbuilder new file mode 100644 index 0000000000..ee21ede9bb --- /dev/null +++ b/app/views/resposta_elems/_resposta_elem.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! resposta_elem, :id, :texto_resposta, :resposta_form_id, :elemento_form_id, :campo_form_id, :created_at, :updated_at +json.url resposta_elem_url(resposta_elem, format: :json) diff --git a/app/views/resposta_elems/edit.html.erb b/app/views/resposta_elems/edit.html.erb new file mode 100644 index 0000000000..dc00e9f6b3 --- /dev/null +++ b/app/views/resposta_elems/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing resposta elem" %> + +

Editing resposta elem

+ +<%= render "form", resposta_elem: @resposta_elem %> + +
+ +
+ <%= link_to "Show this resposta elem", @resposta_elem %> | + <%= link_to "Back to resposta elems", resposta_elems_path %> +
diff --git a/app/views/resposta_elems/index.html.erb b/app/views/resposta_elems/index.html.erb new file mode 100644 index 0000000000..ab277400f0 --- /dev/null +++ b/app/views/resposta_elems/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Resposta elems" %> + +

Resposta elems

+ +
+ <% @resposta_elems.each do |resposta_elem| %> + <%= render resposta_elem %> +

+ <%= link_to "Show this resposta elem", resposta_elem %> +

+ <% end %> +
+ +<%= link_to "New resposta elem", new_resposta_elem_path %> diff --git a/app/views/resposta_elems/index.json.jbuilder b/app/views/resposta_elems/index.json.jbuilder new file mode 100644 index 0000000000..9bedba8ca4 --- /dev/null +++ b/app/views/resposta_elems/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @resposta_elems, partial: "resposta_elems/resposta_elem", as: :resposta_elem diff --git a/app/views/resposta_elems/new.html.erb b/app/views/resposta_elems/new.html.erb new file mode 100644 index 0000000000..b00f55c4cb --- /dev/null +++ b/app/views/resposta_elems/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New resposta elem" %> + +

New resposta elem

+ +<%= render "form", resposta_elem: @resposta_elem %> + +
+ +
+ <%= link_to "Back to resposta elems", resposta_elems_path %> +
diff --git a/app/views/resposta_elems/show.html.erb b/app/views/resposta_elems/show.html.erb new file mode 100644 index 0000000000..4662d00331 --- /dev/null +++ b/app/views/resposta_elems/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @resposta_elem %> + +
+ <%= link_to "Edit this resposta elem", edit_resposta_elem_path(@resposta_elem) %> | + <%= link_to "Back to resposta elems", resposta_elems_path %> + + <%= button_to "Destroy this resposta elem", @resposta_elem, method: :delete %> +
diff --git a/app/views/resposta_elems/show.json.jbuilder b/app/views/resposta_elems/show.json.jbuilder new file mode 100644 index 0000000000..33fcf947e4 --- /dev/null +++ b/app/views/resposta_elems/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "resposta_elems/resposta_elem", resposta_elem: @resposta_elem diff --git a/app/views/resposta_forms/_form.html.erb b/app/views/resposta_forms/_form.html.erb new file mode 100644 index 0000000000..8a1345f86c --- /dev/null +++ b/app/views/resposta_forms/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_with(model: resposta_form) do |form| %> + <% if resposta_form.errors.any? %> +
+

<%= pluralize(resposta_form.errors.count, "error") %> prohibited this resposta_form from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :data_submissao, style: "display: block" %> + <%= form.date_field :data_submissao %> +
+ +
+ <%= form.label :formulario_id, style: "display: block" %> + <%= form.text_field :formulario_id %> +
+ +
+ <%= form.label :usuario_id, style: "display: block" %> + <%= form.text_field :usuario_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/resposta_forms/_resposta_form.html.erb b/app/views/resposta_forms/_resposta_form.html.erb new file mode 100644 index 0000000000..ca137130db --- /dev/null +++ b/app/views/resposta_forms/_resposta_form.html.erb @@ -0,0 +1,17 @@ +
+
+ Data submissao: + <%= resposta_form.data_submissao %> +
+ +
+ Formulario: + <%= resposta_form.formulario_id %> +
+ +
+ Usuario: + <%= resposta_form.usuario_id %> +
+ +
diff --git a/app/views/resposta_forms/_resposta_form.json.jbuilder b/app/views/resposta_forms/_resposta_form.json.jbuilder new file mode 100644 index 0000000000..72ef55e3d3 --- /dev/null +++ b/app/views/resposta_forms/_resposta_form.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! resposta_form, :id, :data_submissao, :formulario_id, :usuario_id, :created_at, :updated_at +json.url resposta_form_url(resposta_form, format: :json) diff --git a/app/views/resposta_forms/edit.html.erb b/app/views/resposta_forms/edit.html.erb new file mode 100644 index 0000000000..787853e439 --- /dev/null +++ b/app/views/resposta_forms/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing resposta form" %> + +

Editing resposta form

+ +<%= render "form", resposta_form: @resposta_form %> + +
+ +
+ <%= link_to "Show this resposta form", @resposta_form %> | + <%= link_to "Back to resposta forms", resposta_forms_path %> +
diff --git a/app/views/resposta_forms/index.html.erb b/app/views/resposta_forms/index.html.erb new file mode 100644 index 0000000000..1680e608d8 --- /dev/null +++ b/app/views/resposta_forms/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Resposta forms" %> + +

Resposta forms

+ +
+ <% @resposta_forms.each do |resposta_form| %> + <%= render resposta_form %> +

+ <%= link_to "Show this resposta form", resposta_form %> +

+ <% end %> +
+ +<%= link_to "New resposta form", new_resposta_form_path %> diff --git a/app/views/resposta_forms/index.json.jbuilder b/app/views/resposta_forms/index.json.jbuilder new file mode 100644 index 0000000000..a4ad662804 --- /dev/null +++ b/app/views/resposta_forms/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @resposta_forms, partial: "resposta_forms/resposta_form", as: :resposta_form diff --git a/app/views/resposta_forms/new.html.erb b/app/views/resposta_forms/new.html.erb new file mode 100644 index 0000000000..82472ef192 --- /dev/null +++ b/app/views/resposta_forms/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New resposta form" %> + +

New resposta form

+ +<%= render "form", resposta_form: @resposta_form %> + +
+ +
+ <%= link_to "Back to resposta forms", resposta_forms_path %> +
diff --git a/app/views/resposta_forms/show.html.erb b/app/views/resposta_forms/show.html.erb new file mode 100644 index 0000000000..e57e7b663c --- /dev/null +++ b/app/views/resposta_forms/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @resposta_form %> + +
+ <%= link_to "Edit this resposta form", edit_resposta_form_path(@resposta_form) %> | + <%= link_to "Back to resposta forms", resposta_forms_path %> + + <%= button_to "Destroy this resposta form", @resposta_form, method: :delete %> +
diff --git a/app/views/resposta_forms/show.json.jbuilder b/app/views/resposta_forms/show.json.jbuilder new file mode 100644 index 0000000000..cf7c6cab1f --- /dev/null +++ b/app/views/resposta_forms/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "resposta_forms/resposta_form", resposta_form: @resposta_form diff --git a/app/views/sessions/new.html.erb b/app/views/sessions/new.html.erb new file mode 100644 index 0000000000..d967f02b26 --- /dev/null +++ b/app/views/sessions/new.html.erb @@ -0,0 +1,31 @@ +
+ +
\ No newline at end of file diff --git a/app/views/templates/_form.html.erb b/app/views/templates/_form.html.erb new file mode 100644 index 0000000000..8901960cb7 --- /dev/null +++ b/app/views/templates/_form.html.erb @@ -0,0 +1,231 @@ + + + + + \ No newline at end of file diff --git a/app/views/templates/_grid.html.erb b/app/views/templates/_grid.html.erb new file mode 100644 index 0000000000..e2951eb863 --- /dev/null +++ b/app/views/templates/_grid.html.erb @@ -0,0 +1,37 @@ +<% if @templates.empty? %> +
+

Nenhum template encontrado.

+ <%= link_to "Criar novo template", new_admin_template_path, class: "btn-figma-success", style: "text-decoration: none;" %> +
+<% else %> +
+ <% @templates.each do |template| %> + + <% next if template.new_record? %> + +
+
+

<%= template.nome %>

+
+ +
+ <%= link_to edit_admin_template_path(@admin, template), class: "action-btn", aria: { label: "Editar" } do %> + <%= svg_icon('edit') %> + <% end %> + + <%= button_to admin_template_path(@admin, template), method: :delete, + form: { data: { turbo_confirm: "..." } }, + class: "action-btn button-to-clean", + aria: { label: "Deletar" } do %> + <%= svg_icon('trash') %> + <% end %> +
+
+ <% end %> + + <%= link_to new_admin_template_path(@admin), class: "card-create-new" do %> + Adicionar novo template + + + <% end %> +
+<% end %> \ No newline at end of file diff --git a/app/views/templates/_template.json.jbuilder b/app/views/templates/_template.json.jbuilder new file mode 100644 index 0000000000..4cffa98a79 --- /dev/null +++ b/app/views/templates/_template.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! template, :id, :nome, :created_at, :updated_at +json.url template_url(template, format: :json) diff --git a/app/views/templates/_template_form.html.erb b/app/views/templates/_template_form.html.erb new file mode 100644 index 0000000000..75ca947616 --- /dev/null +++ b/app/views/templates/_template_form.html.erb @@ -0,0 +1,11 @@ +<%= form_with model: @template, + url: @template.persisted? ? update_admin_template_path(@admin, @template) : create_admin_template_path, + method: @template.persisted? ? :patch : :post do |f| %> + +
+ <%= f.label :nome, "Nome do template:" %> + <%= f.text_field :nome, placeholder: "Digite o nome..." %> +
+ + <%= f.submit @template.persisted? ? "Salvar Alterações" : "Criar Template", class: "btn-save" %> +<% end %> \ No newline at end of file diff --git a/app/views/templates/edit.html.erb b/app/views/templates/edit.html.erb new file mode 100644 index 0000000000..0e96116b60 --- /dev/null +++ b/app/views/templates/edit.html.erb @@ -0,0 +1,2 @@ +<%= render 'grid' %> +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/templates/edit_template.html.erb b/app/views/templates/edit_template.html.erb new file mode 100644 index 0000000000..09df7eee18 --- /dev/null +++ b/app/views/templates/edit_template.html.erb @@ -0,0 +1 @@ +<%= render 'template_form' %> \ No newline at end of file diff --git a/app/views/templates/index.html.erb b/app/views/templates/index.html.erb new file mode 100644 index 0000000000..30669cb98c --- /dev/null +++ b/app/views/templates/index.html.erb @@ -0,0 +1 @@ +<%= render 'grid' %> \ No newline at end of file diff --git a/app/views/templates/index.json.jbuilder b/app/views/templates/index.json.jbuilder new file mode 100644 index 0000000000..5163fa0e1e --- /dev/null +++ b/app/views/templates/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @templates, partial: "templates/template", as: :template diff --git a/app/views/templates/new.html.erb b/app/views/templates/new.html.erb new file mode 100644 index 0000000000..0e96116b60 --- /dev/null +++ b/app/views/templates/new.html.erb @@ -0,0 +1,2 @@ +<%= render 'grid' %> +<%= render 'form' %> \ No newline at end of file diff --git a/app/views/templates/show.json.jbuilder b/app/views/templates/show.json.jbuilder new file mode 100644 index 0000000000..33110ec93b --- /dev/null +++ b/app/views/templates/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "templates/template", template: @template diff --git a/app/views/turmas/_form.html.erb b/app/views/turmas/_form.html.erb new file mode 100644 index 0000000000..fd4628cb48 --- /dev/null +++ b/app/views/turmas/_form.html.erb @@ -0,0 +1,37 @@ +<%= form_with(model: turma) do |form| %> + <% if turma.errors.any? %> +
+

<%= pluralize(turma.errors.count, "error") %> prohibited this turma from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :numero_da_turma, style: "display: block" %> + <%= form.text_field :numero_da_turma %> +
+ +
+ <%= form.label :semestre, style: "display: block" %> + <%= form.text_field :semestre %> +
+ +
+ <%= form.label :horario, style: "display: block" %> + <%= form.text_field :horario %> +
+ +
+ <%= form.label :disciplina_id, style: "display: block" %> + <%= form.text_field :disciplina_id %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/turmas/_turma.html.erb b/app/views/turmas/_turma.html.erb new file mode 100644 index 0000000000..59428ae588 --- /dev/null +++ b/app/views/turmas/_turma.html.erb @@ -0,0 +1,22 @@ +
+
+ Numero da turma: + <%= turma.numero_da_turma %> +
+ +
+ Semestre: + <%= turma.semestre %> +
+ +
+ Horario: + <%= turma.horario %> +
+ +
+ Disciplina: + <%= turma.disciplina_id %> +
+ +
diff --git a/app/views/turmas/_turma.json.jbuilder b/app/views/turmas/_turma.json.jbuilder new file mode 100644 index 0000000000..f5e91fcfa8 --- /dev/null +++ b/app/views/turmas/_turma.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! turma, :id, :numero_da_turma, :semestre, :horario, :disciplina_id, :created_at, :updated_at +json.url turma_url(turma, format: :json) diff --git a/app/views/turmas/edit.html.erb b/app/views/turmas/edit.html.erb new file mode 100644 index 0000000000..108b99a6c2 --- /dev/null +++ b/app/views/turmas/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing turma" %> + +

Editing turma

+ +<%= render "form", turma: @turma %> + +
+ +
+ <%= link_to "Show this turma", @turma %> | + <%= link_to "Back to turmas", turmas_path %> +
diff --git a/app/views/turmas/index.html.erb b/app/views/turmas/index.html.erb new file mode 100644 index 0000000000..72ec97a969 --- /dev/null +++ b/app/views/turmas/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Turmas" %> + +

Turmas

+ +
+ <% @turmas.each do |turma| %> + <%= render turma %> +

+ <%= link_to "Show this turma", turma %> +

+ <% end %> +
+ +<%= link_to "New turma", new_turma_path %> diff --git a/app/views/turmas/index.json.jbuilder b/app/views/turmas/index.json.jbuilder new file mode 100644 index 0000000000..e70b9255db --- /dev/null +++ b/app/views/turmas/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @turmas, partial: "turmas/turma", as: :turma diff --git a/app/views/turmas/new.html.erb b/app/views/turmas/new.html.erb new file mode 100644 index 0000000000..477e3282ff --- /dev/null +++ b/app/views/turmas/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New turma" %> + +

New turma

+ +<%= render "form", turma: @turma %> + +
+ +
+ <%= link_to "Back to turmas", turmas_path %> +
diff --git a/app/views/turmas/show.html.erb b/app/views/turmas/show.html.erb new file mode 100644 index 0000000000..72fb58239d --- /dev/null +++ b/app/views/turmas/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @turma %> + +
+ <%= link_to "Edit this turma", edit_turma_path(@turma) %> | + <%= link_to "Back to turmas", turmas_path %> + + <%= button_to "Destroy this turma", @turma, method: :delete %> +
diff --git a/app/views/turmas/show.json.jbuilder b/app/views/turmas/show.json.jbuilder new file mode 100644 index 0000000000..1d164186aa --- /dev/null +++ b/app/views/turmas/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "turmas/turma", turma: @turma diff --git a/app/views/usuario_mailer/definicao_senha.html.erb b/app/views/usuario_mailer/definicao_senha.html.erb new file mode 100644 index 0000000000..627179a338 --- /dev/null +++ b/app/views/usuario_mailer/definicao_senha.html.erb @@ -0,0 +1,5 @@ +

Olá, <%= @usuario.nome %>.

+ +

Para definir sua senha e acessar o sistema, acesse o link abaixo:

+ +

<%= @url %>

diff --git a/app/views/usuario_mailer/definicao_senha.text.erb b/app/views/usuario_mailer/definicao_senha.text.erb new file mode 100644 index 0000000000..37e8a1dca3 --- /dev/null +++ b/app/views/usuario_mailer/definicao_senha.text.erb @@ -0,0 +1,5 @@ +Olá, <%= @usuario.nome %>. + +Para definir sua senha e acessar o sistema, acesse o link abaixo: + +<%= @url %> diff --git a/app/views/usuario_mailer/redefinicao_senha.html.erb b/app/views/usuario_mailer/redefinicao_senha.html.erb new file mode 100644 index 0000000000..389a9c5176 --- /dev/null +++ b/app/views/usuario_mailer/redefinicao_senha.html.erb @@ -0,0 +1,5 @@ +

Olá, <%= @usuario.nome %>.

+ +

Você solicitou a redefinição da sua senha. Acesse o link abaixo:

+ +

<%= @url %>

diff --git a/app/views/usuario_mailer/redefinicao_senha.text.erb b/app/views/usuario_mailer/redefinicao_senha.text.erb new file mode 100644 index 0000000000..f874bdf5cd --- /dev/null +++ b/app/views/usuario_mailer/redefinicao_senha.text.erb @@ -0,0 +1,5 @@ +Olá, <%= @usuario.nome %>. + +Você solicitou a redefinição da sua senha. Acesse o link abaixo: + +<%= @url %> diff --git a/app/views/usuarios/_form.html.erb b/app/views/usuarios/_form.html.erb new file mode 100644 index 0000000000..6a0bcb7c33 --- /dev/null +++ b/app/views/usuarios/_form.html.erb @@ -0,0 +1,42 @@ +<%= form_with(model: usuario) do |form| %> + <% if usuario.errors.any? %> +
+

<%= pluralize(usuario.errors.count, "error") %> prohibited this usuario from being saved:

+ + +
+ <% end %> + +
+ <%= form.label :matricula, style: "display: block" %> + <%= form.text_field :matricula %> +
+ +
+ <%= form.label :email, style: "display: block" %> + <%= form.text_field :email %> +
+ +
+ <%= form.label :nome, style: "display: block" %> + <%= form.text_field :nome %> +
+ +
+ <%= form.label :formacao, style: "display: block" %> + <%= form.text_field :formacao %> +
+ +
+ <%= form.label :type, style: "display: block" %> + <%= form.text_field :type %> +
+ +
+ <%= form.submit %> +
+<% end %> diff --git a/app/views/usuarios/_usuario.html.erb b/app/views/usuarios/_usuario.html.erb new file mode 100644 index 0000000000..6defd9c276 --- /dev/null +++ b/app/views/usuarios/_usuario.html.erb @@ -0,0 +1,27 @@ +
+
+ Matricula: + <%= usuario.matricula %> +
+ +
+ Email: + <%= usuario.email %> +
+ +
+ Nome: + <%= usuario.nome %> +
+ +
+ Formacao: + <%= usuario.formacao %> +
+ +
+ Type: + <%= usuario.type %> +
+ +
diff --git a/app/views/usuarios/_usuario.json.jbuilder b/app/views/usuarios/_usuario.json.jbuilder new file mode 100644 index 0000000000..4f0dd1450d --- /dev/null +++ b/app/views/usuarios/_usuario.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! usuario, :id, :matricula, :email, :nome, :formacao, :type, :created_at, :updated_at +json.url usuario_url(usuario, format: :json) diff --git a/app/views/usuarios/edit.html.erb b/app/views/usuarios/edit.html.erb new file mode 100644 index 0000000000..670af5b784 --- /dev/null +++ b/app/views/usuarios/edit.html.erb @@ -0,0 +1,12 @@ +<% content_for :title, "Editing usuario" %> + +

Editing usuario

+ +<%= render "form", usuario: @usuario %> + +
+ +
+ <%= link_to "Show this usuario", @usuario %> | + <%= link_to "Back to usuarios", usuarios_path %> +
diff --git a/app/views/usuarios/index.html.erb b/app/views/usuarios/index.html.erb new file mode 100644 index 0000000000..53b9428ddc --- /dev/null +++ b/app/views/usuarios/index.html.erb @@ -0,0 +1,16 @@ +

<%= notice %>

+ +<% content_for :title, "Usuarios" %> + +

Usuarios

+ +
+ <% @usuarios.each do |usuario| %> + <%= render usuario %> +

+ <%= link_to "Show this usuario", usuario %> +

+ <% end %> +
+ +<%= link_to "New usuario", new_usuario_path %> diff --git a/app/views/usuarios/index.json.jbuilder b/app/views/usuarios/index.json.jbuilder new file mode 100644 index 0000000000..b7fdb3ce8f --- /dev/null +++ b/app/views/usuarios/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @usuarios, partial: "usuarios/usuario", as: :usuario diff --git a/app/views/usuarios/new.html.erb b/app/views/usuarios/new.html.erb new file mode 100644 index 0000000000..8a2c9f08cc --- /dev/null +++ b/app/views/usuarios/new.html.erb @@ -0,0 +1,11 @@ +<% content_for :title, "New usuario" %> + +

New usuario

+ +<%= render "form", usuario: @usuario %> + +
+ +
+ <%= link_to "Back to usuarios", usuarios_path %> +
diff --git a/app/views/usuarios/show.html.erb b/app/views/usuarios/show.html.erb new file mode 100644 index 0000000000..ae4030189d --- /dev/null +++ b/app/views/usuarios/show.html.erb @@ -0,0 +1,10 @@ +

<%= notice %>

+ +<%= render @usuario %> + +
+ <%= link_to "Edit this usuario", edit_usuario_path(@usuario) %> | + <%= link_to "Back to usuarios", usuarios_path %> + + <%= button_to "Destroy this usuario", @usuario, method: :delete %> +
diff --git a/app/views/usuarios/show.json.jbuilder b/app/views/usuarios/show.json.jbuilder new file mode 100644 index 0000000000..ad071a9501 --- /dev/null +++ b/app/views/usuarios/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "usuarios/usuario", usuario: @usuario diff --git a/bin/brakeman b/bin/brakeman new file mode 100755 index 0000000000..ace1c9ba08 --- /dev/null +++ b/bin/brakeman @@ -0,0 +1,7 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +ARGV.unshift("--ensure-latest") + +load Gem.bin_path("brakeman", "brakeman") diff --git a/bin/bundler-audit b/bin/bundler-audit new file mode 100755 index 0000000000..e2ef22690c --- /dev/null +++ b/bin/bundler-audit @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "bundler/audit/cli" + +ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check") +Bundler::Audit::CLI.start diff --git a/bin/ci b/bin/ci new file mode 100755 index 0000000000..4137ad5bb0 --- /dev/null +++ b/bin/ci @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "active_support/continuous_integration" + +CI = ActiveSupport::ContinuousIntegration +require_relative "../config/ci.rb" diff --git a/bin/cucumber b/bin/cucumber new file mode 100755 index 0000000000..eb5e962e86 --- /dev/null +++ b/bin/cucumber @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +vendored_cucumber_bin = Dir["#{File.dirname(__FILE__)}/../vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +if vendored_cucumber_bin + load File.expand_path(vendored_cucumber_bin) +else + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'cucumber' + load Cucumber::BINARY +end diff --git a/bin/dev b/bin/dev new file mode 100755 index 0000000000..5f91c20545 --- /dev/null +++ b/bin/dev @@ -0,0 +1,2 @@ +#!/usr/bin/env ruby +exec "./bin/rails", "server", *ARGV diff --git a/bin/docker-entrypoint b/bin/docker-entrypoint new file mode 100755 index 0000000000..ed31659f40 --- /dev/null +++ b/bin/docker-entrypoint @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# If running the rails server then create or migrate existing database +if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then + ./bin/rails db:prepare +fi + +exec "${@}" diff --git a/bin/importmap b/bin/importmap new file mode 100755 index 0000000000..36502ab16c --- /dev/null +++ b/bin/importmap @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby + +require_relative "../config/application" +require "importmap/commands" diff --git a/bin/jobs b/bin/jobs new file mode 100755 index 0000000000..dcf59f309a --- /dev/null +++ b/bin/jobs @@ -0,0 +1,6 @@ +#!/usr/bin/env ruby + +require_relative "../config/environment" +require "solid_queue/cli" + +SolidQueue::Cli.start(ARGV) diff --git a/bin/kamal b/bin/kamal new file mode 100755 index 0000000000..d9ba276702 --- /dev/null +++ b/bin/kamal @@ -0,0 +1,16 @@ +#!/usr/bin/env ruby +# frozen_string_literal: true + +# +# This file was generated by Bundler. +# +# The application 'kamal' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("kamal", "kamal") diff --git a/bin/rails b/bin/rails new file mode 100755 index 0000000000..efc0377492 --- /dev/null +++ b/bin/rails @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +APP_PATH = File.expand_path("../config/application", __dir__) +require_relative "../config/boot" +require "rails/commands" diff --git a/bin/rake b/bin/rake new file mode 100755 index 0000000000..4fbf10b960 --- /dev/null +++ b/bin/rake @@ -0,0 +1,4 @@ +#!/usr/bin/env ruby +require_relative "../config/boot" +require "rake" +Rake.application.run diff --git a/bin/rubocop b/bin/rubocop new file mode 100755 index 0000000000..5a20504716 --- /dev/null +++ b/bin/rubocop @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +# Explicit RuboCop config increases performance slightly while avoiding config confusion. +ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__)) + +load Gem.bin_path("rubocop", "rubocop") diff --git a/bin/setup b/bin/setup new file mode 100755 index 0000000000..81be011e87 --- /dev/null +++ b/bin/setup @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby +require "fileutils" + +APP_ROOT = File.expand_path("..", __dir__) + +def system!(*args) + system(*args, exception: true) +end + +FileUtils.chdir APP_ROOT do + # This script is a way to set up or update your development environment automatically. + # This script is idempotent, so that you can run it at any time and get an expectable outcome. + # Add necessary setup steps to this file. + + puts "== Installing dependencies ==" + system("bundle check") || system!("bundle install") + + # puts "\n== Copying sample files ==" + # unless File.exist?("config/database.yml") + # FileUtils.cp "config/database.yml.sample", "config/database.yml" + # end + + puts "\n== Preparing database ==" + system! "bin/rails db:prepare" + system! "bin/rails db:reset" if ARGV.include?("--reset") + + puts "\n== Removing old logs and tempfiles ==" + system! "bin/rails log:clear tmp:clear" + + unless ARGV.include?("--skip-server") + puts "\n== Starting development server ==" + STDOUT.flush # flush the output before exec(2) so that it displays + exec "bin/dev" + end +end diff --git a/bin/thrust b/bin/thrust new file mode 100755 index 0000000000..36bde2d832 --- /dev/null +++ b/bin/thrust @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby +require "rubygems" +require "bundler/setup" + +load Gem.bin_path("thruster", "thrust") diff --git a/config.ru b/config.ru new file mode 100644 index 0000000000..4a3c09a688 --- /dev/null +++ b/config.ru @@ -0,0 +1,6 @@ +# This file is used by Rack-based servers to start the application. + +require_relative "config/environment" + +run Rails.application +Rails.application.load_server diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 0000000000..b4848d838b --- /dev/null +++ b/config/application.rb @@ -0,0 +1,27 @@ +require_relative "boot" + +require "rails/all" + +# Require the gems listed in Gemfile, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(*Rails.groups) + +module Camaar + class Application < Rails::Application + # Initialize configuration defaults for originally generated Rails version. + config.load_defaults 8.1 + + # Please, add to the `ignore` list any other `lib` subdirectories that do + # not contain `.rb` files, or that should not be reloaded or eager loaded. + # Common ones are `templates`, `generators`, or `middleware`, for example. + config.autoload_lib(ignore: %w[assets tasks]) + + # Configuration for the application, engines, and railties goes here. + # + # These settings can be overridden in specific environments using the files + # in config/environments, which are processed later. + # + # config.time_zone = "Central Time (US & Canada)" + # config.eager_load_paths << Rails.root.join("extras") + end +end diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000..988a5ddc46 --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,4 @@ +ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) + +require "bundler/setup" # Set up gems listed in the Gemfile. +require "bootsnap/setup" # Speed up boot time by caching expensive operations. diff --git a/config/bundler-audit.yml b/config/bundler-audit.yml new file mode 100644 index 0000000000..e74b3af949 --- /dev/null +++ b/config/bundler-audit.yml @@ -0,0 +1,5 @@ +# Audit all gems listed in the Gemfile for known security problems by running bin/bundler-audit. +# CVEs that are not relevant to the application can be enumerated on the ignore list below. + +ignore: + - CVE-THAT-DOES-NOT-APPLY diff --git a/config/cable.yml b/config/cable.yml new file mode 100644 index 0000000000..b9adc5aa3a --- /dev/null +++ b/config/cable.yml @@ -0,0 +1,17 @@ +# Async adapter only works within the same process, so for manually triggering cable updates from a console, +# and seeing results in the browser, you must do so from the web console (running inside the dev process), +# not a terminal started via bin/rails console! Add "console" to any action or any ERB template view +# to make the web console appear. +development: + adapter: async + +test: + adapter: test + +production: + adapter: solid_cable + connects_to: + database: + writing: cable + polling_interval: 0.1.seconds + message_retention: 1.day diff --git a/config/cache.yml b/config/cache.yml new file mode 100644 index 0000000000..19d490843b --- /dev/null +++ b/config/cache.yml @@ -0,0 +1,16 @@ +default: &default + store_options: + # Cap age of oldest cache entry to fulfill retention policies + # max_age: <%= 60.days.to_i %> + max_size: <%= 256.megabytes %> + namespace: <%= Rails.env %> + +development: + <<: *default + +test: + <<: *default + +production: + database: cache + <<: *default diff --git a/config/ci.rb b/config/ci.rb new file mode 100644 index 0000000000..1712cc1127 --- /dev/null +++ b/config/ci.rb @@ -0,0 +1,24 @@ +# Run using bin/ci + +CI.run do + step "Setup", "bin/setup --skip-server" + + step "Style: Ruby", "bin/rubocop" + + step "Security: Gem audit", "bin/bundler-audit" + step "Security: Importmap vulnerability audit", "bin/importmap audit" + step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error" + step "Tests: Rails", "bin/rails test" + step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant" + + # Optional: Run system tests + # step "Tests: System", "bin/rails test:system" + + # Optional: set a green GitHub commit status to unblock PR merge. + # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`. + # if success? + # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff" + # else + # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again." + # end +end diff --git a/config/credentials.yml.enc b/config/credentials.yml.enc new file mode 100644 index 0000000000..09eb287f93 --- /dev/null +++ b/config/credentials.yml.enc @@ -0,0 +1 @@ +4H8/6nhnfIn9qW6hDXeaYIPA3qXldZwgNhgvx+L1Hn7mBFhEYQcclgYI+WiUqPbhcvtdzm5FkhaDaTb0TfUCfFTkLfIEdJs9kC+pEBilNfOdzMTTT2d6KeVGNO+BSu/dfxec7YQpsiICdabItL3av/dmoSA9KwDP75Ep+RDAQBXllNWAqBy5zIz1Cnb+/q7doDz2oj+F/Or1Go+v32WzZNm7dbJ4AW3EHJw2L8k82sVmawg8x6i2ehcCNHALQZO/lB3nT6IY0ZkkOxzALaUroqVlgEe+695GkTe08bNTPLrE5l4XSs1edC8V47RTO/ieO9EqHxU3hKvpH7Xdot1P0D6WI6G/koAAzzHnE2jvb4VU6UCIkAXs2mp7L954yxqNgEZ9KOymqNOmancSSStMXp7O5KCiiN6BQCx8ydLaNgScImfwC9dWCiquZOv8Km36dAfzE92TbZUNogOxA5Uw7xEIrjH4Jrg7JDBqM34mJnWW1j5ZX+Fz5Zld--9oy00/0iz+TVEIu/--wUtORdaSWiIGCttp56iN7g== \ No newline at end of file diff --git a/config/cucumber.yml b/config/cucumber.yml new file mode 100644 index 0000000000..47a4663ae2 --- /dev/null +++ b/config/cucumber.yml @@ -0,0 +1,8 @@ +<% +rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" +rerun = rerun.strip.gsub /\s/, ' ' +rerun_opts = rerun.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" +std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags 'not @wip'" +%> +default: <%= std_opts %> features +rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags 'not @wip' diff --git a/config/database.yml b/config/database.yml new file mode 100644 index 0000000000..1b87315456 --- /dev/null +++ b/config/database.yml @@ -0,0 +1,34 @@ +default: &default + adapter: mysql2 + encoding: utf8mb4 + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + username: root + password: aluno + socket: /var/run/mysqld/mysqld.sock + +development: + <<: *default + database: camaar_development + +test: + <<: *default + database: camaar_test + +production: + primary: &primary_production + <<: *default + database: camaar_production + username: camaar + password: <%= ENV["CAMAAR_DATABASE_PASSWORD"] %> + cache: + <<: *primary_production + database: camaar_production_cache + migrations_paths: db/cache_migrate + queue: + <<: *primary_production + database: camaar_production_queue + migrations_paths: db/queue_migrate + cable: + <<: *primary_production + database: camaar_production_cable + migrations_paths: db/cable_migrate diff --git a/config/deploy.yml b/config/deploy.yml new file mode 100644 index 0000000000..501ac950fe --- /dev/null +++ b/config/deploy.yml @@ -0,0 +1,119 @@ +# Name of your application. Used to uniquely configure containers. +service: camaar + +# Name of the container image (use your-user/app-name on external registries). +image: camaar + +# Deploy to these servers. +servers: + web: + - 192.168.0.1 + # job: + # hosts: + # - 192.168.0.1 + # cmd: bin/jobs + +# Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server. +# If used with Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption. +# +# Using an SSL proxy like this requires turning on config.assume_ssl and config.force_ssl in production.rb! +# +# Don't use this when deploying to multiple web servers (then you have to terminate SSL at your load balancer). +# +# proxy: +# ssl: true +# host: app.example.com + +# Where you keep your container images. +registry: + # Alternatives: hub.docker.com / registry.digitalocean.com / ghcr.io / ... + server: localhost:5555 + + # Needed for authenticated registries. + # username: your-user + + # Always use an access token rather than real password when possible. + # password: + # - KAMAL_REGISTRY_PASSWORD + +# Inject ENV variables into containers (secrets come from .kamal/secrets). +env: + secret: + - RAILS_MASTER_KEY + clear: + # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs. + # When you start using multiple servers, you should split out job processing to a dedicated machine. + SOLID_QUEUE_IN_PUMA: true + + # Set number of processes dedicated to Solid Queue (default: 1) + # JOB_CONCURRENCY: 3 + + # Set number of cores available to the application on each server (default: 1). + # WEB_CONCURRENCY: 2 + + # Match this to any external database server to configure Active Record correctly + # Use camaar-db for a db accessory server on same machine via local kamal docker network. + # DB_HOST: 192.168.0.2 + + # Log everything from Rails + # RAILS_LOG_LEVEL: debug + +# Aliases are triggered with "bin/kamal ". You can overwrite arguments on invocation: +# "bin/kamal logs -r job" will tail logs from the first server in the job section. +aliases: + console: app exec --interactive --reuse "bin/rails console" + shell: app exec --interactive --reuse "bash" + logs: app logs -f + dbc: app exec --interactive --reuse "bin/rails dbconsole --include-password" + +# Use a persistent storage volume for sqlite database files and local Active Storage files. +# Recommended to change this to a mounted volume path that is backed up off server. +volumes: + - "camaar_storage:/rails/storage" + +# Bridge fingerprinted assets, like JS and CSS, between versions to avoid +# hitting 404 on in-flight requests. Combines all files from new and old +# version inside the asset_path. +asset_path: /rails/public/assets + +# Configure the image builder. +builder: + arch: amd64 + + # # Build image via remote server (useful for faster amd64 builds on arm64 computers) + # remote: ssh://docker@docker-builder-server + # + # # Pass arguments and secrets to the Docker build process + # args: + # RUBY_VERSION: 4.0.2 + # secrets: + # - GITHUB_TOKEN + # - RAILS_MASTER_KEY + +# Use a different ssh user than root +# ssh: +# user: app + +# Use accessory services (secrets come from .kamal/secrets). +# accessories: +# db: +# image: mysql:8.0 +# host: 192.168.0.2 +# # Change to 3306 to expose port to the world instead of just local network. +# port: "127.0.0.1:3306:3306" +# env: +# clear: +# MYSQL_ROOT_HOST: '%' +# secret: +# - MYSQL_ROOT_PASSWORD +# files: +# - config/mysql/production.cnf:/etc/mysql/my.cnf +# - db/production.sql:/docker-entrypoint-initdb.d/setup.sql +# directories: +# - data:/var/lib/mysql +# redis: +# image: valkey/valkey:8 +# host: 192.168.0.2 +# port: 6379 +# directories: +# - data:/data diff --git a/config/environment.rb b/config/environment.rb new file mode 100644 index 0000000000..cac5315775 --- /dev/null +++ b/config/environment.rb @@ -0,0 +1,5 @@ +# Load the Rails application. +require_relative "application" + +# Initialize the Rails application. +Rails.application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb new file mode 100644 index 0000000000..da8e70d7ad --- /dev/null +++ b/config/environments/development.rb @@ -0,0 +1,99 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Configure 'rails notes' to inspect Cucumber files + config.annotations.register_directories("features") + config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + + # Settings specified here will take precedence over those in config/application.rb. + + # Make code changes take effect immediately without server restart. + config.enable_reloading = true + + # Do not eager load code on boot. + config.eager_load = false + + # Show full error reports. + config.consider_all_requests_local = true + + # Enable server timing. + config.server_timing = true + + # Enable/disable Action Controller caching. By default Action Controller caching is disabled. + # Run rails dev:cache to toggle Action Controller caching. + if Rails.root.join("tmp/caching-dev.txt").exist? + config.action_controller.perform_caching = true + config.action_controller.enable_fragment_cache_logging = true + config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" } + else + config.action_controller.perform_caching = false + end + + # Change to :null_store to avoid any caching. + config.cache_store = :memory_store + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Don't care if the mailer can't send. + config.action_mailer.raise_delivery_errors = true + + # Make template changes take effect immediately. + config.action_mailer.perform_caching = false + + # Set localhost to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { + host: ENV.fetch("APP_HOST", "localhost:3000"), + protocol: ENV.fetch("APP_PROTOCOL", "http") + } + + # Gmail SMTP configuration via environment variables + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV.fetch("SMTP_ADDRESS", "smtp.gmail.com"), + port: ENV.fetch("SMTP_PORT", 587).to_i, + domain: ENV.fetch("SMTP_DOMAIN", "gmail.com"), + user_name: ENV.fetch("SMTP_USERNAME", ""), + password: ENV.fetch("SMTP_PASSWORD", ""), + authentication: :plain, + enable_starttls_auto: true, + open_timeout: 10, + read_timeout: 10 + } + + # Print deprecation notices to the Rails logger. + config.active_support.deprecation = :log + + # Raise an error on page load if there are pending migrations. + config.active_record.migration_error = :page_load + + # Highlight code that triggered database queries in logs. + config.active_record.verbose_query_logs = true + + # Append comments with runtime information tags to SQL queries in logs. + config.active_record.query_log_tags_enabled = true + + # Highlight code that enqueued background job in logs. + config.active_job.verbose_enqueue_logs = true + + # Highlight code that triggered redirect in logs. + config.action_dispatch.verbose_redirect_logs = true + + # Suppress logger output for asset requests. + config.assets.quiet = true + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + config.action_view.annotate_rendered_view_with_filenames = true + + # Uncomment if you wish to allow Action Cable access from any origin. + # config.action_cable.disable_request_forgery_protection = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true + + # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. + # config.generators.apply_rubocop_autocorrect_after_generate! +end diff --git a/config/environments/production.rb b/config/environments/production.rb new file mode 100644 index 0000000000..f7a4759303 --- /dev/null +++ b/config/environments/production.rb @@ -0,0 +1,98 @@ +require "active_support/core_ext/integer/time" + +Rails.application.configure do + # Settings specified here will take precedence over those in config/application.rb. + + # Code is not reloaded between requests. + config.enable_reloading = false + + # Eager load code on boot for better performance and memory savings (ignored by Rake tasks). + config.eager_load = true + + # Full error reports are disabled. + config.consider_all_requests_local = false + + # Turn on fragment caching in view templates. + config.action_controller.perform_caching = true + + # Cache assets for far-future expiry since they are all digest stamped. + config.public_file_server.headers = { "cache-control" => "public, max-age=#{1.year.to_i}" } + + # Enable serving of images, stylesheets, and JavaScripts from an asset server. + # config.asset_host = "http://assets.example.com" + + # Store uploaded files on the local file system (see config/storage.yml for options). + config.active_storage.service = :local + + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # config.assume_ssl = true + + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. + # config.force_ssl = true + + # Skip http-to-https redirect for the default health check endpoint. + # config.ssl_options = { redirect: { exclude: ->(request) { request.path == "/up" } } } + + # Log to STDOUT with the current request id as a default log tag. + config.log_tags = [ :request_id ] + config.logger = ActiveSupport::TaggedLogging.logger(STDOUT) + + # Change to "debug" to log everything (including potentially personally-identifiable information!). + config.log_level = ENV.fetch("RAILS_LOG_LEVEL", "info") + + # Prevent health checks from clogging up the logs. + config.silence_healthcheck_path = "/up" + + # Don't log any deprecations. + config.active_support.report_deprecations = false + + # Replace the default in-process memory cache store with a durable alternative. + config.cache_store = :solid_cache_store + + # Replace the default in-process and non-durable queuing backend for Active Job. + config.active_job.queue_adapter = :solid_queue + config.solid_queue.connects_to = { database: { writing: :queue } } + + # Ignore bad email addresses and do not raise email delivery errors. + # Set this to true and configure the email server for immediate delivery to raise delivery errors. + config.action_mailer.raise_delivery_errors = true + + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { + host: ENV.fetch("APP_HOST", "example.com"), + protocol: ENV.fetch("APP_PROTOCOL", "https") + } + + # Gmail SMTP configuration via environment variables + config.action_mailer.delivery_method = :smtp + config.action_mailer.smtp_settings = { + address: ENV.fetch("SMTP_ADDRESS", "smtp.gmail.com"), + port: ENV.fetch("SMTP_PORT", 587).to_i, + domain: ENV.fetch("SMTP_DOMAIN", "gmail.com"), + user_name: ENV.fetch("SMTP_USERNAME", ""), + password: ENV.fetch("SMTP_PASSWORD", ""), + authentication: :plain, + enable_starttls_auto: true, + open_timeout: 10, + read_timeout: 10 + } + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation cannot be found). + config.i18n.fallbacks = true + + # Do not dump schema after migrations. + config.active_record.dump_schema_after_migration = false + + # Only use :id for inspections in production. + config.active_record.attributes_for_inspect = [ :id ] + + # Enable DNS rebinding protection and other `Host` header attacks. + # config.hosts = [ + # "example.com", # Allow requests from example.com + # /.*\.example\.com/ # Allow requests from subdomains like `www.example.com` + # ] + # + # Skip DNS rebinding protection for the default health check endpoint. + # config.host_authorization = { exclude: ->(request) { request.path == "/up" } } +end diff --git a/config/environments/test.rb b/config/environments/test.rb new file mode 100644 index 0000000000..29d195b837 --- /dev/null +++ b/config/environments/test.rb @@ -0,0 +1,57 @@ +# The test environment is used exclusively to run your application's +# test suite. You never need to work with it otherwise. Remember that +# your test database is "scratch space" for the test suite and is wiped +# and recreated between test runs. Don't rely on the data there! + +Rails.application.configure do + # Configure 'rails notes' to inspect Cucumber files + config.annotations.register_directories("features") + config.annotations.register_extensions("feature") { |tag| /#\s*(#{tag}):?\s*(.*)$/ } + + # Settings specified here will take precedence over those in config/application.rb. + + # While tests run files are not watched, reloading is not necessary. + config.enable_reloading = false + + # Eager loading loads your entire application. When running a single test locally, + # this is usually not necessary, and can slow down your test suite. However, it's + # recommended that you enable it in continuous integration systems to ensure eager + # loading is working properly before deploying your code. + config.eager_load = ENV["CI"].present? + + # Configure public file server for tests with cache-control for performance. + config.public_file_server.headers = { "cache-control" => "public, max-age=3600" } + + # Show full error reports. + config.consider_all_requests_local = true + config.cache_store = :null_store + + # Render exception templates for rescuable exceptions and raise for other exceptions. + config.action_dispatch.show_exceptions = :rescuable + + # Disable request forgery protection in test environment. + config.action_controller.allow_forgery_protection = false + + # Store uploaded files on the local file system in a temporary directory. + config.active_storage.service = :test + + # Tell Action Mailer not to deliver emails to the real world. + # The :test delivery method accumulates sent emails in the + # ActionMailer::Base.deliveries array. + config.action_mailer.delivery_method = :test + + # Set host to be used by links generated in mailer templates. + config.action_mailer.default_url_options = { host: "example.com" } + + # Print deprecation notices to the stderr. + config.active_support.deprecation = :stderr + + # Raises error for missing translations. + # config.i18n.raise_on_missing_translations = true + + # Annotate rendered view with file names. + # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions. + config.action_controller.raise_on_missing_callback_actions = true +end diff --git a/config/importmap.rb b/config/importmap.rb new file mode 100644 index 0000000000..909dfc542d --- /dev/null +++ b/config/importmap.rb @@ -0,0 +1,7 @@ +# Pin npm packages by running ./bin/importmap + +pin "application" +pin "@hotwired/turbo-rails", to: "turbo.min.js" +pin "@hotwired/stimulus", to: "stimulus.min.js" +pin "@hotwired/stimulus-loading", to: "stimulus-loading.js" +pin_all_from "app/javascript/controllers", under: "controllers" diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb new file mode 100644 index 0000000000..487324424f --- /dev/null +++ b/config/initializers/assets.rb @@ -0,0 +1,7 @@ +# Be sure to restart your server when you modify this file. + +# Version of your assets, change this if you want to expire all your assets. +Rails.application.config.assets.version = "1.0" + +# Add additional assets to the asset load path. +# Rails.application.config.assets.paths << Emoji.images_path diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb new file mode 100644 index 0000000000..d51d713979 --- /dev/null +++ b/config/initializers/content_security_policy.rb @@ -0,0 +1,29 @@ +# Be sure to restart your server when you modify this file. + +# Define an application-wide content security policy. +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header + +# Rails.application.configure do +# config.content_security_policy do |policy| +# policy.default_src :self, :https +# policy.font_src :self, :https, :data +# policy.img_src :self, :https, :data +# policy.object_src :none +# policy.script_src :self, :https +# policy.style_src :self, :https +# # Specify URI for violation reports +# # policy.report_uri "/csp-violation-report-endpoint" +# end +# +# # Generate session nonces for permitted importmap, inline scripts, and inline styles. +# config.content_security_policy_nonce_generator = ->(request) { request.session.id.to_s } +# config.content_security_policy_nonce_directives = %w(script-src style-src) +# +# # Automatically add `nonce` to `javascript_tag`, `javascript_include_tag`, and `stylesheet_link_tag` +# # if the corresponding directives are specified in `content_security_policy_nonce_directives`. +# # config.content_security_policy_nonce_auto = true +# +# # Report violations without enforcing the policy. +# # config.content_security_policy_report_only = true +# end diff --git a/config/initializers/filter_parameter_logging.rb b/config/initializers/filter_parameter_logging.rb new file mode 100644 index 0000000000..c0b717f7ec --- /dev/null +++ b/config/initializers/filter_parameter_logging.rb @@ -0,0 +1,8 @@ +# Be sure to restart your server when you modify this file. + +# Configure parameters to be partially matched (e.g. passw matches password) and filtered from the log file. +# Use this to limit dissemination of sensitive information. +# See the ActiveSupport::ParameterFilter documentation for supported notations and behaviors. +Rails.application.config.filter_parameters += [ + :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc +] diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb new file mode 100644 index 0000000000..3860f659ea --- /dev/null +++ b/config/initializers/inflections.rb @@ -0,0 +1,16 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format. Inflections +# are locale specific, and you may define rules for as many different +# locales as you wish. All of these examples are active by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.plural /^(ox)$/i, "\\1en" +# inflect.singular /^(ox)en/i, "\\1" +# inflect.irregular "person", "people" +# inflect.uncountable %w( fish sheep ) +# end + +# These inflection rules are supported but not enabled by default: +# ActiveSupport::Inflector.inflections(:en) do |inflect| +# inflect.acronym "RESTful" +# end diff --git a/config/locales/en.yml b/config/locales/en.yml new file mode 100644 index 0000000000..6c349ae5e3 --- /dev/null +++ b/config/locales/en.yml @@ -0,0 +1,31 @@ +# 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. +# +# To learn more about the API, please read the Rails Internationalization guide +# at https://guides.rubyonrails.org/i18n.html. +# +# Be aware that YAML interprets the following case-insensitive strings as +# booleans: `true`, `false`, `on`, `off`, `yes`, `no`. Therefore, these strings +# must be quoted to be interpreted as strings. For example: +# +# en: +# "yes": yup +# enabled: "ON" + +en: + hello: "Hello world" diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000000..38c4b86596 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,42 @@ +# This configuration file will be evaluated by Puma. The top-level methods that +# are invoked here are part of Puma's configuration DSL. For more information +# about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. +# +# Puma starts a configurable number of processes (workers) and each process +# serves each request in a thread from an internal thread pool. +# +# You can control the number of workers using ENV["WEB_CONCURRENCY"]. You +# should only set this value when you want to run 2 or more workers. The +# default is already 1. You can set it to `auto` to automatically start a worker +# for each available processor. +# +# The ideal number of threads per worker depends both on how much time the +# application spends waiting for IO operations and on how much you wish to +# prioritize throughput over latency. +# +# As a rule of thumb, increasing the number of threads will increase how much +# traffic a given process can handle (throughput), but due to CRuby's +# Global VM Lock (GVL) it has diminishing returns and will degrade the +# response time (latency) of the application. +# +# The default is set to 3 threads as it's deemed a decent compromise between +# throughput and latency for the average Rails application. +# +# Any libraries that use a connection pool or another resource pool should +# be configured to provide at least as many connections as the number of +# threads. This includes Active Record's `pool` parameter in `database.yml`. +threads_count = ENV.fetch("RAILS_MAX_THREADS", 3) +threads threads_count, threads_count + +# Specifies the `port` that Puma will listen on to receive requests; default is 3000. +port ENV.fetch("PORT", 3000) + +# Allow puma to be restarted by `bin/rails restart` command. +plugin :tmp_restart + +# Run the Solid Queue supervisor inside of Puma for single-server deployments. +plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"] + +# Specify the PID file. Defaults to tmp/pids/server.pid in development. +# In other environments, only set the PID file if requested. +pidfile ENV["PIDFILE"] if ENV["PIDFILE"] diff --git a/config/queue.yml b/config/queue.yml new file mode 100644 index 0000000000..9eace59c41 --- /dev/null +++ b/config/queue.yml @@ -0,0 +1,18 @@ +default: &default + dispatchers: + - polling_interval: 1 + batch_size: 500 + workers: + - queues: "*" + threads: 3 + processes: <%= ENV.fetch("JOB_CONCURRENCY", 1) %> + polling_interval: 0.1 + +development: + <<: *default + +test: + <<: *default + +production: + <<: *default diff --git a/config/recurring.yml b/config/recurring.yml new file mode 100644 index 0000000000..b4207f9b07 --- /dev/null +++ b/config/recurring.yml @@ -0,0 +1,15 @@ +# examples: +# periodic_cleanup: +# class: CleanSoftDeletedRecordsJob +# queue: background +# args: [ 1000, { batch_size: 500 } ] +# schedule: every hour +# periodic_cleanup_with_command: +# command: "SoftDeletedRecord.due.delete_all" +# priority: 2 +# schedule: at 5am every day + +production: + clear_solid_queue_finished_jobs: + command: "SolidQueue::Job.clear_finished_in_batches(sleep_between_batches: 0.3)" + schedule: every hour at minute 12 diff --git a/config/routes.rb b/config/routes.rb new file mode 100644 index 0000000000..375d2c55fb --- /dev/null +++ b/config/routes.rb @@ -0,0 +1,63 @@ +Rails.application.routes.draw do + root "sessions#new" + + get "/inicio", to: "home#index", as: :inicio + post "/login", to: "sessions#create", as: :login + delete "/logout", to: "sessions#destroy", as: :logout + + get "/definir_senha/:token", to: "definicao_senhas#edit", as: :edit_definicao_senha + patch "/definir_senha/:token", to: "definicao_senhas#update", as: :definicao_senha + + get "/redefinir_senha", to: "redefinicao_senhas#new", as: :redefinir_senha + post "/redefinir_senha", to: "redefinicao_senhas#create" + get "/redefinir_senha/:token", to: "redefinicao_senhas#edit", as: :edit_redefinicao_senha + patch "/redefinir_senha/:token", to: "redefinicao_senhas#update", as: :redefinicao_senha + + resources :resposta_elems + resources :resposta_forms + resources :campo_forms + resources :elemento_forms + resources :formularios + resources :campos + resources :elementos + resources :docentes + resources :discentes + resources :usuarios + resources :turmas + resources :disciplinas + resources :cursos + resources :departamentos + + # User forms (responder avaliações) + resources :forms, only: [ :index, :show ] do + member do + post :create_response + end + end + + # Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500. + get "/up" => "rails/health#show", as: :rails_health_check + + # Admin routes + namespace :admin do + get "/", to: redirect("/admin/avaliacoes") + + get "avaliacoes", to: "dashboard#index" + get "gerenciamento", to: "dashboard#gerenciamento" + + resources :forms, only: [ :index, :new, :create ] do + member do + post :publish + get :results + end + end + + resources :templates + + get "sincronizar_sigaa", to: "dashboard#sincronizar_sigaa", as: :sincronizar_sigaa + post "sincronizar_sigaa", to: "dashboard#sincronizar_sigaa" + end + + get "/admin/resultados", to: "admin#resultados", as: :admin_resultados + get "/admin/resultados/:id/download.csv", to: "admin#exportar_csv", as: :baixar_csv +end diff --git a/config/storage.yml b/config/storage.yml new file mode 100644 index 0000000000..927dc537c8 --- /dev/null +++ b/config/storage.yml @@ -0,0 +1,27 @@ +test: + service: Disk + root: <%= Rails.root.join("tmp/storage") %> + +local: + service: Disk + root: <%= Rails.root.join("storage") %> + +# Use bin/rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key) +# amazon: +# service: S3 +# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %> +# secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %> +# region: us-east-1 +# bucket: your_own_bucket-<%= Rails.env %> + +# Remember not to checkin your GCS keyfile to a repository +# google: +# service: GCS +# project: your_project +# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %> +# bucket: your_own_bucket-<%= Rails.env %> + +# mirror: +# service: Mirror +# primary: local +# mirrors: [ amazon, google, microsoft ] diff --git a/db/cable_schema.rb b/db/cable_schema.rb new file mode 100644 index 0000000000..23666604a5 --- /dev/null +++ b/db/cable_schema.rb @@ -0,0 +1,11 @@ +ActiveRecord::Schema[7.1].define(version: 1) do + create_table "solid_cable_messages", force: :cascade do |t| + t.binary "channel", limit: 1024, null: false + t.binary "payload", limit: 536870912, null: false + t.datetime "created_at", null: false + t.integer "channel_hash", limit: 8, null: false + t.index ["channel"], name: "index_solid_cable_messages_on_channel" + t.index ["channel_hash"], name: "index_solid_cable_messages_on_channel_hash" + t.index ["created_at"], name: "index_solid_cable_messages_on_created_at" + end +end diff --git a/db/cache_schema.rb b/db/cache_schema.rb new file mode 100644 index 0000000000..81a410d188 --- /dev/null +++ b/db/cache_schema.rb @@ -0,0 +1,12 @@ +ActiveRecord::Schema[7.2].define(version: 1) do + create_table "solid_cache_entries", force: :cascade do |t| + t.binary "key", limit: 1024, null: false + t.binary "value", limit: 536870912, null: false + t.datetime "created_at", null: false + t.integer "key_hash", limit: 8, null: false + t.integer "byte_size", limit: 4, null: false + t.index ["byte_size"], name: "index_solid_cache_entries_on_byte_size" + t.index ["key_hash", "byte_size"], name: "index_solid_cache_entries_on_key_hash_and_byte_size" + t.index ["key_hash"], name: "index_solid_cache_entries_on_key_hash", unique: true + end +end diff --git a/db/migrate/20260527234832_create_departamentos.rb b/db/migrate/20260527234832_create_departamentos.rb new file mode 100644 index 0000000000..d68e988470 --- /dev/null +++ b/db/migrate/20260527234832_create_departamentos.rb @@ -0,0 +1,11 @@ +class CreateDepartamentos < ActiveRecord::Migration[8.1] + def change + create_table :departamentos do |t| + t.string :codigo + t.string :nome + + t.timestamps + end + add_index :departamentos, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234834_create_cursos.rb b/db/migrate/20260527234834_create_cursos.rb new file mode 100644 index 0000000000..df00ece751 --- /dev/null +++ b/db/migrate/20260527234834_create_cursos.rb @@ -0,0 +1,12 @@ +class CreateCursos < ActiveRecord::Migration[8.1] + def change + create_table :cursos do |t| + t.string :codigo + t.string :nome + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :cursos, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234836_create_disciplinas.rb b/db/migrate/20260527234836_create_disciplinas.rb new file mode 100644 index 0000000000..3792bd4359 --- /dev/null +++ b/db/migrate/20260527234836_create_disciplinas.rb @@ -0,0 +1,12 @@ +class CreateDisciplinas < ActiveRecord::Migration[8.1] + def change + create_table :disciplinas do |t| + t.string :codigo + t.string :nome + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :disciplinas, :codigo, unique: true + end +end diff --git a/db/migrate/20260527234838_create_turmas.rb b/db/migrate/20260527234838_create_turmas.rb new file mode 100644 index 0000000000..6cebbbbf67 --- /dev/null +++ b/db/migrate/20260527234838_create_turmas.rb @@ -0,0 +1,12 @@ +class CreateTurmas < ActiveRecord::Migration[8.1] + def change + create_table :turmas do |t| + t.string :numero_da_turma + t.string :semestre + t.string :horario + t.references :disciplina, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235010_create_usuarios.rb b/db/migrate/20260527235010_create_usuarios.rb new file mode 100644 index 0000000000..0810d70635 --- /dev/null +++ b/db/migrate/20260527235010_create_usuarios.rb @@ -0,0 +1,17 @@ +class CreateUsuarios < ActiveRecord::Migration[8.1] + def change + create_table :usuarios do |t| + t.string :matricula + t.string :senha_hash + t.string :email + t.string :nome + t.string :formacao + t.string :type + t.references :curso, null: false, foreign_key: true + t.references :departamento, null: false, foreign_key: true + + t.timestamps + end + add_index :usuarios, :matricula, unique: true + end +end diff --git a/db/migrate/20260527235026_create_templates.rb b/db/migrate/20260527235026_create_templates.rb new file mode 100644 index 0000000000..0170a38e2c --- /dev/null +++ b/db/migrate/20260527235026_create_templates.rb @@ -0,0 +1,9 @@ +class CreateTemplates < ActiveRecord::Migration[8.1] + def change + create_table :templates do |t| + t.string :nome + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235028_create_elementos.rb b/db/migrate/20260527235028_create_elementos.rb new file mode 100644 index 0000000000..0f606f6609 --- /dev/null +++ b/db/migrate/20260527235028_create_elementos.rb @@ -0,0 +1,11 @@ +class CreateElementos < ActiveRecord::Migration[8.1] + def change + create_table :elementos do |t| + t.integer :ordem + t.string :enunciado + t.references :template, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235031_create_campos.rb b/db/migrate/20260527235031_create_campos.rb new file mode 100644 index 0000000000..2eed8b9a65 --- /dev/null +++ b/db/migrate/20260527235031_create_campos.rb @@ -0,0 +1,12 @@ +class CreateCampos < ActiveRecord::Migration[8.1] + def change + create_table :campos do |t| + t.integer :ordem + t.string :enunciado + t.string :tipo_elemento + t.references :elemento, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235053_create_formularios.rb b/db/migrate/20260527235053_create_formularios.rb new file mode 100644 index 0000000000..a0db30072f --- /dev/null +++ b/db/migrate/20260527235053_create_formularios.rb @@ -0,0 +1,9 @@ +class CreateFormularios < ActiveRecord::Migration[8.1] + def change + create_table :formularios do |t| + t.references :turma, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235055_create_elemento_forms.rb b/db/migrate/20260527235055_create_elemento_forms.rb new file mode 100644 index 0000000000..af930be937 --- /dev/null +++ b/db/migrate/20260527235055_create_elemento_forms.rb @@ -0,0 +1,11 @@ +class CreateElementoForms < ActiveRecord::Migration[8.1] + def change + create_table :elemento_forms do |t| + t.integer :ordem + t.string :enunciado + t.references :formulario, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235057_create_campo_forms.rb b/db/migrate/20260527235057_create_campo_forms.rb new file mode 100644 index 0000000000..383ec9749f --- /dev/null +++ b/db/migrate/20260527235057_create_campo_forms.rb @@ -0,0 +1,11 @@ +class CreateCampoForms < ActiveRecord::Migration[8.1] + def change + create_table :campo_forms do |t| + t.integer :ordem + t.string :enunciado + t.references :elemento_form, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235101_create_resposta_forms.rb b/db/migrate/20260527235101_create_resposta_forms.rb new file mode 100644 index 0000000000..6e8b112723 --- /dev/null +++ b/db/migrate/20260527235101_create_resposta_forms.rb @@ -0,0 +1,11 @@ +class CreateRespostaForms < ActiveRecord::Migration[8.1] + def change + create_table :resposta_forms do |t| + t.date :data_submissao + t.references :formulario, null: false, foreign_key: true + t.references :usuario, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260527235104_create_resposta_elems.rb b/db/migrate/20260527235104_create_resposta_elems.rb new file mode 100644 index 0000000000..8c9aa6fba9 --- /dev/null +++ b/db/migrate/20260527235104_create_resposta_elems.rb @@ -0,0 +1,12 @@ +class CreateRespostaElems < ActiveRecord::Migration[8.1] + def change + create_table :resposta_elems do |t| + t.text :texto_resposta + t.references :resposta_form, null: false, foreign_key: true + t.references :elemento_form, null: false, foreign_key: true + t.references :campo_form, null: false, foreign_key: true + + t.timestamps + end + end +end diff --git a/db/migrate/20260528000107_create_join_table_discente_turma.rb b/db/migrate/20260528000107_create_join_table_discente_turma.rb new file mode 100644 index 0000000000..caf907c424 --- /dev/null +++ b/db/migrate/20260528000107_create_join_table_discente_turma.rb @@ -0,0 +1,8 @@ +class CreateJoinTableDiscenteTurma < ActiveRecord::Migration[8.1] + def change + create_join_table :discentes, :turmas do |t| + # t.index [:discente_id, :turma_id] + # t.index [:turma_id, :discente_id] + end + end +end diff --git a/db/migrate/20260528000109_create_join_table_docente_turma.rb b/db/migrate/20260528000109_create_join_table_docente_turma.rb new file mode 100644 index 0000000000..962b882b0c --- /dev/null +++ b/db/migrate/20260528000109_create_join_table_docente_turma.rb @@ -0,0 +1,8 @@ +class CreateJoinTableDocenteTurma < ActiveRecord::Migration[8.1] + def change + create_join_table :docentes, :turmas do |t| + # t.index [:docente_id, :turma_id] + # t.index [:turma_id, :docente_id] + end + end +end diff --git a/db/migrate/20260528002258_ajusta_nulos_para_sti.rb b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb new file mode 100644 index 0000000000..c6d3c678ec --- /dev/null +++ b/db/migrate/20260528002258_ajusta_nulos_para_sti.rb @@ -0,0 +1,7 @@ +class AjustaNulosParaSti < ActiveRecord::Migration[8.1] + def change + change_column_null :usuarios, :curso_id, true + change_column_null :usuarios, :departamento_id, true + change_column_null :resposta_elems, :campo_form_id, true + end +end diff --git a/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb b/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb new file mode 100644 index 0000000000..8a8f0ed497 --- /dev/null +++ b/db/migrate/20260601120000_add_definicao_senha_to_usuarios.rb @@ -0,0 +1,8 @@ +class AddDefinicaoSenhaToUsuarios < ActiveRecord::Migration[8.1] + def change + add_column :usuarios, :definicao_senha_token, :string + add_column :usuarios, :definicao_senha_sent_at, :datetime + + add_index :usuarios, :definicao_senha_token, unique: true + end +end diff --git a/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb b/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb new file mode 100644 index 0000000000..11ab0be88e --- /dev/null +++ b/db/migrate/20260602090000_add_redefinicao_senha_to_usuarios.rb @@ -0,0 +1,8 @@ +class AddRedefinicaoSenhaToUsuarios < ActiveRecord::Migration[8.1] + def change + add_column :usuarios, :redefinicao_senha_token, :string + add_column :usuarios, :redefinicao_senha_sent_at, :datetime + + add_index :usuarios, :redefinicao_senha_token, unique: true + end +end diff --git a/db/migrate/20260615105458_add_usuario_to_templates.rb b/db/migrate/20260615105458_add_usuario_to_templates.rb new file mode 100644 index 0000000000..ae90001208 --- /dev/null +++ b/db/migrate/20260615105458_add_usuario_to_templates.rb @@ -0,0 +1,5 @@ +class AddUsuarioToTemplates < ActiveRecord::Migration[8.1] + def change + add_reference :templates, :usuario, null: false, foreign_key: true + end +end diff --git a/db/migrate/20260615220605_create_workspace_states.rb b/db/migrate/20260615220605_create_workspace_states.rb new file mode 100644 index 0000000000..c9a45ad28d --- /dev/null +++ b/db/migrate/20260615220605_create_workspace_states.rb @@ -0,0 +1,8 @@ +class CreateWorkspaceStates < ActiveRecord::Migration[8.1] + def change + create_table :workspace_states do |t| + t.json :data, null: false + t.timestamps + end + end +end diff --git a/db/queue_schema.rb b/db/queue_schema.rb new file mode 100644 index 0000000000..85194b6a88 --- /dev/null +++ b/db/queue_schema.rb @@ -0,0 +1,129 @@ +ActiveRecord::Schema[7.1].define(version: 1) do + create_table "solid_queue_blocked_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.string "concurrency_key", null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.index [ "concurrency_key", "priority", "job_id" ], name: "index_solid_queue_blocked_executions_for_release" + t.index [ "expires_at", "concurrency_key" ], name: "index_solid_queue_blocked_executions_for_maintenance" + t.index [ "job_id" ], name: "index_solid_queue_blocked_executions_on_job_id", unique: true + end + + create_table "solid_queue_claimed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.bigint "process_id" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_claimed_executions_on_job_id", unique: true + t.index [ "process_id", "job_id" ], name: "index_solid_queue_claimed_executions_on_process_id_and_job_id" + end + + create_table "solid_queue_failed_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.text "error" + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_failed_executions_on_job_id", unique: true + end + + create_table "solid_queue_jobs", force: :cascade do |t| + t.string "queue_name", null: false + t.string "class_name", null: false + t.text "arguments" + t.integer "priority", default: 0, null: false + t.string "active_job_id" + t.datetime "scheduled_at" + t.datetime "finished_at" + t.string "concurrency_key" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "active_job_id" ], name: "index_solid_queue_jobs_on_active_job_id" + t.index [ "class_name" ], name: "index_solid_queue_jobs_on_class_name" + t.index [ "finished_at" ], name: "index_solid_queue_jobs_on_finished_at" + t.index [ "queue_name", "finished_at" ], name: "index_solid_queue_jobs_for_filtering" + t.index [ "scheduled_at", "finished_at" ], name: "index_solid_queue_jobs_for_alerting" + end + + create_table "solid_queue_pauses", force: :cascade do |t| + t.string "queue_name", null: false + t.datetime "created_at", null: false + t.index [ "queue_name" ], name: "index_solid_queue_pauses_on_queue_name", unique: true + end + + create_table "solid_queue_processes", force: :cascade do |t| + t.string "kind", null: false + t.datetime "last_heartbeat_at", null: false + t.bigint "supervisor_id" + t.integer "pid", null: false + t.string "hostname" + t.text "metadata" + t.datetime "created_at", null: false + t.string "name", null: false + t.index [ "last_heartbeat_at" ], name: "index_solid_queue_processes_on_last_heartbeat_at" + t.index [ "name", "supervisor_id" ], name: "index_solid_queue_processes_on_name_and_supervisor_id", unique: true + t.index [ "supervisor_id" ], name: "index_solid_queue_processes_on_supervisor_id" + end + + create_table "solid_queue_ready_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_ready_executions_on_job_id", unique: true + t.index [ "priority", "job_id" ], name: "index_solid_queue_poll_all" + t.index [ "queue_name", "priority", "job_id" ], name: "index_solid_queue_poll_by_queue" + end + + create_table "solid_queue_recurring_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "task_key", null: false + t.datetime "run_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_recurring_executions_on_job_id", unique: true + t.index [ "task_key", "run_at" ], name: "index_solid_queue_recurring_executions_on_task_key_and_run_at", unique: true + end + + create_table "solid_queue_recurring_tasks", force: :cascade do |t| + t.string "key", null: false + t.string "schedule", null: false + t.string "command", limit: 2048 + t.string "class_name" + t.text "arguments" + t.string "queue_name" + t.integer "priority", default: 0 + t.boolean "static", default: true, null: false + t.text "description" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "key" ], name: "index_solid_queue_recurring_tasks_on_key", unique: true + t.index [ "static" ], name: "index_solid_queue_recurring_tasks_on_static" + end + + create_table "solid_queue_scheduled_executions", force: :cascade do |t| + t.bigint "job_id", null: false + t.string "queue_name", null: false + t.integer "priority", default: 0, null: false + t.datetime "scheduled_at", null: false + t.datetime "created_at", null: false + t.index [ "job_id" ], name: "index_solid_queue_scheduled_executions_on_job_id", unique: true + t.index [ "scheduled_at", "priority", "job_id" ], name: "index_solid_queue_dispatch_all" + end + + create_table "solid_queue_semaphores", force: :cascade do |t| + t.string "key", null: false + t.integer "value", default: 1, null: false + t.datetime "expires_at", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index [ "expires_at" ], name: "index_solid_queue_semaphores_on_expires_at" + t.index [ "key", "value" ], name: "index_solid_queue_semaphores_on_key_and_value" + t.index [ "key" ], name: "index_solid_queue_semaphores_on_key", unique: true + end + + add_foreign_key "solid_queue_blocked_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_claimed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_failed_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_ready_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_recurring_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade + add_foreign_key "solid_queue_scheduled_executions", "solid_queue_jobs", column: "job_id", on_delete: :cascade +end diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000000..9d531662cb --- /dev/null +++ b/db/schema.rb @@ -0,0 +1,180 @@ +# This file is auto-generated from the current state of the database. Instead +# of editing this file, please use the migrations feature of Active Record to +# incrementally modify your database, and then regenerate this schema definition. +# +# This file is the source Rails uses to define your schema when running `bin/rails +# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to +# be faster and is potentially less error prone than running all of your +# migrations from scratch. Old migrations may fail to apply correctly if those +# migrations use external dependencies or application code. +# +# It's strongly recommended that you check this file into your version control system. + +ActiveRecord::Schema[8.1].define(version: 2026_06_15_220605) do + create_table "campo_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "elemento_form_id", null: false + t.string "enunciado" + t.integer "ordem" + t.datetime "updated_at", null: false + t.index ["elemento_form_id"], name: "index_campo_forms_on_elemento_form_id" + end + + create_table "campos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "elemento_id", null: false + t.string "enunciado" + t.integer "ordem" + t.string "tipo_elemento" + t.datetime "updated_at", null: false + t.index ["elemento_id"], name: "index_campos_on_elemento_id" + end + + create_table "cursos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.bigint "departamento_id", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_cursos_on_codigo", unique: true + t.index ["departamento_id"], name: "index_cursos_on_departamento_id" + end + + create_table "departamentos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_departamentos_on_codigo", unique: true + end + + create_table "discentes_turmas", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "discente_id", null: false + t.bigint "turma_id", null: false + end + + create_table "disciplinas", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.string "codigo" + t.datetime "created_at", null: false + t.bigint "departamento_id", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.index ["codigo"], name: "index_disciplinas_on_codigo", unique: true + t.index ["departamento_id"], name: "index_disciplinas_on_departamento_id" + end + + create_table "docentes_turmas", id: false, charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "docente_id", null: false + t.bigint "turma_id", null: false + end + + create_table "elemento_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "enunciado" + t.bigint "formulario_id", null: false + t.integer "ordem" + t.datetime "updated_at", null: false + t.index ["formulario_id"], name: "index_elemento_forms_on_formulario_id" + end + + create_table "elementos", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "enunciado" + t.integer "ordem" + t.bigint "template_id", null: false + t.datetime "updated_at", null: false + t.index ["template_id"], name: "index_elementos_on_template_id" + end + + create_table "formularios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "turma_id", null: false + t.datetime "updated_at", null: false + t.index ["turma_id"], name: "index_formularios_on_turma_id" + end + + create_table "resposta_elems", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.bigint "campo_form_id" + t.datetime "created_at", null: false + t.bigint "elemento_form_id", null: false + t.bigint "resposta_form_id", null: false + t.text "texto_resposta" + t.datetime "updated_at", null: false + t.index ["campo_form_id"], name: "index_resposta_elems_on_campo_form_id" + t.index ["elemento_form_id"], name: "index_resposta_elems_on_elemento_form_id" + t.index ["resposta_form_id"], name: "index_resposta_elems_on_resposta_form_id" + end + + create_table "resposta_forms", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.date "data_submissao" + t.bigint "formulario_id", null: false + t.datetime "updated_at", null: false + t.bigint "usuario_id", null: false + t.index ["formulario_id"], name: "index_resposta_forms_on_formulario_id" + t.index ["usuario_id"], name: "index_resposta_forms_on_usuario_id" + end + + create_table "templates", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.string "nome" + t.datetime "updated_at", null: false + t.bigint "usuario_id", null: false + t.index ["usuario_id"], name: "index_templates_on_usuario_id" + end + + create_table "turmas", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "disciplina_id", null: false + t.string "horario" + t.string "numero_da_turma" + t.string "semestre" + t.datetime "updated_at", null: false + t.index ["disciplina_id"], name: "index_turmas_on_disciplina_id" + end + + create_table "usuarios", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.bigint "curso_id" + t.datetime "definicao_senha_sent_at" + t.string "definicao_senha_token" + t.bigint "departamento_id" + t.string "email" + t.string "formacao" + t.string "matricula" + t.string "nome" + t.datetime "redefinicao_senha_sent_at" + t.string "redefinicao_senha_token" + t.string "senha_hash" + t.string "type" + t.datetime "updated_at", null: false + t.index ["curso_id"], name: "index_usuarios_on_curso_id" + t.index ["definicao_senha_token"], name: "index_usuarios_on_definicao_senha_token", unique: true + t.index ["departamento_id"], name: "index_usuarios_on_departamento_id" + t.index ["matricula"], name: "index_usuarios_on_matricula", unique: true + t.index ["redefinicao_senha_token"], name: "index_usuarios_on_redefinicao_senha_token", unique: true + end + + create_table "workspace_states", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t| + t.datetime "created_at", null: false + t.json "data", null: false + t.datetime "updated_at", null: false + end + + add_foreign_key "campo_forms", "elemento_forms" + add_foreign_key "campos", "elementos" + add_foreign_key "cursos", "departamentos" + add_foreign_key "disciplinas", "departamentos" + add_foreign_key "elemento_forms", "formularios" + add_foreign_key "elementos", "templates" + add_foreign_key "formularios", "turmas" + add_foreign_key "resposta_elems", "campo_forms" + add_foreign_key "resposta_elems", "elemento_forms" + add_foreign_key "resposta_elems", "resposta_forms" + add_foreign_key "resposta_forms", "formularios" + add_foreign_key "resposta_forms", "usuarios" + add_foreign_key "templates", "usuarios" + add_foreign_key "turmas", "disciplinas" + add_foreign_key "usuarios", "cursos" + add_foreign_key "usuarios", "departamentos" +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 0000000000..8439338128 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,210 @@ +# Departamentos +dept_cic = Departamento.find_or_create_by!(codigo: "CIC") do |d| + d.nome = "Ciência da Computação" +end + +dept_mat = Departamento.find_or_create_by!(codigo: "MAT") do |d| + d.nome = "Matemática" +end + +# Cursos +curso_cc = Curso.find_or_create_by!(codigo: "CC") do |c| + c.nome = "Bacharelado em Ciência da Computação" + c.departamento = dept_cic +end + +# Disciplinas +disc_ed = Disciplina.find_or_create_by!(codigo: "CIC0001") do |d| + d.nome = "Estrutura de Dados" + d.departamento = dept_cic +end + +disc_isc = Disciplina.find_or_create_by!(codigo: "CIC0002") do |d| + d.nome = "Introdução aos Sistemas de Computação" + d.departamento = dept_cic +end + +disc_apc = Disciplina.find_or_create_by!(codigo: "CIC0003") do |d| + d.nome = "Algoritmos e Programação de Computadores" + d.departamento = dept_cic +end + +# Turmas +turma_ed_a = Turma.find_or_create_by!(numero_da_turma: "A", semestre: "2026.1", disciplina: disc_ed) do |t| + t.horario = "35T23" +end + +turma_ed_b = Turma.find_or_create_by!(numero_da_turma: "B", semestre: "2026.1", disciplina: disc_ed) do |t| + t.horario = "35M23" +end + +# Introdução aos Sistemas de Computação - Turma A +turma_isc_a = Turma.find_or_create_by!(numero_da_turma: "A", semestre: "2026.1", disciplina: disc_isc) do |t| + t.horario = "24T23" +end + +# Docentes +docente_1 = Docente.find_or_initialize_by(email: "docente1@teste.com") +docente_1.nome ||= "Professor de ED" +docente_1.matricula ||= "241000001" +docente_1.senha = "teste123" +docente_1.senha_confirmation = "teste123" +docente_1.departamento = dept_cic +docente_1.formacao = "doutorado" +docente_1.save! + +docente_2 = Docente.find_or_initialize_by(email: "docente2@teste.com") +docente_2.nome ||= "Professor de ISC" +docente_2.matricula ||= "241000011" +docente_2.senha = "teste123" +docente_2.senha_confirmation = "teste123" +docente_2.departamento = dept_cic +docente_2.formacao = "doutorado" +docente_2.save! + +# Admin +admin = Administrador.find_or_initialize_by(email: "admin@teste.com") +admin.update!( + nome: "Admin Teste", + matricula: "240000003", + senha: "teste123", + senha_confirmation: "teste123", + departamento: dept_cic +) unless admin.persisted? + +# Discentes (Lista de novos alunos) +alunos_dados = [ + { email: "discente1@teste.com", nome: "Ana Silva", matricula: "241000002" }, + { email: "discente2@teste.com", nome: "Bruno Santos", matricula: "241000004" }, + { email: "discente3@teste.com", nome: "Carlos Oliveira", matricula: "241000005" }, + { email: "discente4@teste.com", nome: "Diana Costa", matricula: "241000006" }, + { email: "discente5@teste.com", nome: "Eduardo Ribeiro", matricula: "241000007" } +] + +alunos = alunos_dados.map do |dados| + aluno = Discente.find_or_initialize_by(email: dados[:email]) + aluno.nome ||= dados[:nome] + aluno.matricula ||= dados[:matricula] + aluno.senha = "teste123" + aluno.senha_confirmation = "teste123" + aluno.curso = curso_cc + aluno.save! + aluno +end + +# ========================================== +# VINCULANDO USUÁRIOS ÀS TURMAS +# ========================================== + +# Professores nas turmas +docente_1.turmas << turma_ed_a unless docente_1.turmas.include?(turma_ed_a) +docente_1.turmas << turma_ed_b unless docente_1.turmas.include?(turma_ed_b) +docente_2.turmas << turma_isc_a unless docente_2.turmas.include?(turma_isc_a) + +# Turma ED A: Alunos 1, 2 e 3 +[alunos[0], alunos[1], alunos[2]].each do |aluno| + aluno.turmas << turma_ed_a unless aluno.turmas.include?(turma_ed_a) +end + +# Turma ED B: Alunos 3, 4 e 5 +[alunos[2], alunos[3], alunos[4]].each do |aluno| + aluno.turmas << turma_ed_b unless aluno.turmas.include?(turma_ed_b) +end + +# Turma ISC A: Alunos 1, 4 e 5 +[alunos[0], alunos[4], alunos[3]].each do |aluno| + aluno.turmas << turma_isc_a unless aluno.turmas.include?(turma_isc_a) +end + +# ========================================== +# TEMPLATES E ESTRUTURA BASE DE FORMULÁRIOS +# ========================================== +template = Template.find_or_initialize_by(nome: "Avaliação de Disciplina Padrão") + +if template.new_record? + elemento_nota = template.elementos.build(enunciado: "Avalie a didática do professor", ordem: 1) + (1..5).each do |valor| + elemento_nota.campos.build(enunciado: valor.to_s, ordem: valor, tipo_elemento: "Múltipla Escolha") + end + + elemento_opcoes = template.elementos.build(enunciado: "Como você avalia a dificuldade das listas de exercícios?", ordem: 2) + ["Muito Fácil", "Adequada", "Muito Difícil"].each_with_index do |opcao, index| + elemento_opcoes.campos.build(enunciado: opcao, ordem: index + 1, tipo_elemento: "Múltipla Escolha") + end + + elemento_texto = template.elementos.build(enunciado: "Deixe um comentário ou sugestão sobre a disciplina", ordem: 3) + elemento_texto.campos.build(enunciado: nil, ordem: 1, tipo_elemento: "Texto") + + template.save! +end + +# ========================================== +# FORMULÁRIOS DAS TURMAS E RESPOSTAS +# ========================================== + +def configurar_formulario_e_respostas(turma, template_base, dados_alunos) + formulario = Formulario.find_or_create_by!(turma: turma) + + template_base.elementos.order(:ordem).each do |elemento_base| + ef = ElementoForm.find_or_create_by!(enunciado: elemento_base.enunciado, formulario: formulario) do |e| + e.ordem = elemento_base.ordem + end + + elemento_base.campos.order(:ordem).each do |campo_base| + CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |c| + c.ordem = campo_base.ordem + end + end + end + + dados_alunos.each do |dado| + aluno = dado[:aluno] + respostas = dado[:respostas] + + resposta_form = RespostaForm.find_or_create_by!(formulario: formulario, usuario: aluno) do |rf| + rf.data_submissao = Date.today + end + + formulario.elemento_forms.order(:ordem).each_with_index do |ef, index| + texto_respondido = respostas[index].to_s + cf = ef.campo_forms.find_by(enunciado: texto_respondido) || ef.campo_forms.first + + RespostaElem.find_or_create_by!(resposta_form: resposta_form, elemento_form: ef) do |re| + re.texto_resposta = texto_respondido + re.campo_form = cf + end + end + end +end + +configurar_formulario_e_respostas( + turma_ed_a, + template, + [ + { aluno: alunos[0], respostas: ["5", "Adequada", "Ótima didática, recomendo!"] }, + { aluno: alunos[1], respostas: ["4", "Muito Difícil", "As listas poderiam ter mais exemplos práticos."] }, + { aluno: alunos[2], respostas: ["5", "Adequada", "Sem reclamações, matéria excelente."] } + ] +) + +configurar_formulario_e_respostas( + turma_ed_b, + template, + [ + { aluno: alunos[2], respostas: ["3", "Muito Difícil", "O ritmo das aulas está muito acelerado."] }, + { aluno: alunos[3], respostas: ["4", "Adequada", "Gostei da metodologia."] }, + { aluno: alunos[4], respostas: ["2", "Muito Difícil", "Preciso de mais monitoria para acompanhar."] } + ] +) + +configurar_formulario_e_respostas( + turma_isc_a, + template, + [ + { aluno: alunos[0], respostas: ["5", "Muito Fácil", "Projetos práticos são muito divertidos!"] }, + { aluno: alunos[4], respostas: ["5", "Adequada", "O professor tira todas as dúvidas e os projetos ajudam muito."] }, + { aluno: alunos[3], respostas: ["4", "Adequada", "Gostaria de mais exercícios de fixação antes das provas."] } + ] +) + +puts "Seeds finalizados com sucesso! Campos padronizados como Texto e Múltipla Escolha." diff --git a/features/atualizar_dados_sigaa.feature b/features/atualizar_dados_sigaa.feature new file mode 100644 index 0000000000..97087df8ac --- /dev/null +++ b/features/atualizar_dados_sigaa.feature @@ -0,0 +1,27 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Atualizar base de dados do sistema com dados do SIGAA + Eu, como Administrador + Quero atualizar os dados de turmas, matérias e participantes do sistema com os dados atuais do SIGAA + A fim de corrigir a base de dados do sistema + +Contexto: + Dado que estou na página de gerenciamento + E que os dados do SIGAA foram importados com sucesso + +Cenário: Atualização de dados do SIGAA (happy path) + Dado que os dados do SIGAA foram atualizados com sucesso + Então as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA + +Cenário: Atualização de dados do SIGAA com falha (sad path) + Dado que eu tentei atualizar os dados do SIGAA mas ocorreu um erro + Então uma mensagem de erro é exibida informando que a atualização falhou + +Cenário: Atualização de dados do SIGAA com dados já atualizados (sad path) + Dado que os dados do SIGAA já estão atualizados na base de dados do sistema + Então uma mensagem é exibida informando que os dados já estão atualizados e não serão atualizados novamente + +Cenário: Atualização de dados do SIGAA com dados parcialmente atualizados (sad path) + Dado que alguns dados do SIGAA já estão atualizados na base de dados do sistema + Então uma mensagem é exibida informando que alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso diff --git a/features/cadastro_sigaa.feature b/features/cadastro_sigaa.feature new file mode 100644 index 0000000000..9f169a5f07 --- /dev/null +++ b/features/cadastro_sigaa.feature @@ -0,0 +1,13 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Cadastrar usuários do sistema + Eu, como Administrador + Quero cadastrar participantes de turmas do SIGAA ao importar dados de usuarios novos para o sistema + A fim de que eles acessem o sistema CAMAAR + + Cenário: Cadastro de usuário importado do SIGAA (happy path) + Dado que estou na página de gerenciamento + Dado que eu importei os dados do SIGAA com sucesso + Então o e-mail de usuário "usuario@teste.com" está cadastrado no sistema com senha indefinida + E um email de definição de senha é enviado para o email "usuario@teste.com" \ No newline at end of file diff --git a/features/create_template.feature b/features/create_template.feature new file mode 100644 index 0000000000..113a061868 --- /dev/null +++ b/features/create_template.feature @@ -0,0 +1,60 @@ +Feature: Create Template + + Eu como Administrador + Quero criar um template de formulário contendo as questões do formulário + A fim de gerar formulários de avaliações para avaliar o desempenho das turmas + + Background: + Given I Am authenticated as an "Administrador" + Given I Am on the home page + And I follow "Adicionar novo template" + And I am on the "Criar novo template" page + + Scenario: Create a template successfully(happy path) + + # Teste de matematica, multipla escolha + And I have added the template + | titulo | Template Prova Matemática 2º semestre | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão desafio(1 ponto): | multipla_escolha | a: b: c: d: | + When I press "Salvar" + Then I should see a success message "Template criado com sucesso!" + + # Teste de portugues, discursivo + When I follow "Adicionar novo template" + Given I have added the template + | titulo | Template Prova Português 2º semestre | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 2(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 3(2.5 pontos): | campo_de_texto | Resposta: | + | Questão 4(2.5 pontos): | campo_de_texto | Resposta: | + | Questão desafio(1 ponto): | campo_de_texto | Resposta: | + When I press "Salvar" + Then I should see a success message "Template criado com sucesso!" + + # verificacao final (visualizacao) + And the template "Template Prova Matemática 2º semestre" should be listed in my templates + And the template "Template Prova Português 2º semestre" should be listed in my templates + + Scenario: Attempt to create a template without a title(sad path) + Given I have added the template + | titulo | "" | + And I add the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1: | multipla_escolha | a: b: c: d: | + When I press "Salvar" + Then I should see an error message "Título não pode ficar em branco!" + + Scenario: Attempt to create a template without questions(sad path) + Given I have added the template + | titulo | Template Prova Matemática 2º semestre | + And I dont add elementos + When I press "Salvar" + Then I should see an error message "Template deve ter pelo menos um elemento!" diff --git a/features/criar_formulario.feature b/features/criar_formulario.feature new file mode 100644 index 0000000000..7ebcad2ffd --- /dev/null +++ b/features/criar_formulario.feature @@ -0,0 +1,23 @@ +# language: pt + +Funcionalidade: Criar formulário de avaliação + Como um professor ou administrador + Quero poder criar um formulário de avaliação + Para que os alunos possam avaliar a disciplina ou turma + + Contexto: + Dado que eu estou logado como professor + E eu estou na página de criação de formulários + + Cenário: Criação de formulário com sucesso (Happy Path) + Quando eu preencho o título com "Avaliação de Turma 2026.1" + E eu adiciono uma pergunta do tipo "Múltipla Escolha" com o texto "Como você avalia o professor?" + E eu clico em "Salvar Formulário" + Então eu devo ver a mensagem "Formulário criado com sucesso" + E eu devo ver o formulário "Avaliação de Turma 2026.1" na lista de formulários + + Cenário: Tentativa de criação sem título (Sad Path) + Quando eu deixo o título em branco + E eu adiciono uma pergunta do tipo "Texto" com o texto "Quais suas sugestões?" + E eu clico em "Salvar Formulário" + Então eu devo ver a mensagem "Título não pode ficar em branco" diff --git a/features/criar_formulario_template.feature b/features/criar_formulario_template.feature new file mode 100644 index 0000000000..d420bdec7f --- /dev/null +++ b/features/criar_formulario_template.feature @@ -0,0 +1,57 @@ +# language: pt + +Funcionalidade: Criar formulário baseado em template + Como um administrador + Quero criar um formulário baseado em um template para as turmas que eu escolher + A fim de avaliar o desempenho das turmas no semestre atual + + Contexto: + Dado que eu estou logado como administrador + E que existe um template chamado "Avaliação Padrão" com as seguintes perguntas: + | Pergunta | Tipo | Opções | + | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | + | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | + | Deixe seu comentário | Texto | | + E que existem as seguintes turmas no semestre "2026.1": + | Código | Disciplina | Turma | + | TEC001 | Matemática | A | + | TEC002 | Português | B | + | TEC003 | História | A | + + Cenário: Criar formulário a partir de template para uma turma (Happy Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu seleciono as turmas "TEC001 - Matemática - A" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Formulário criado com sucesso" + E o formulário deve conter as perguntas do template "Avaliação Padrão" + E o formulário deve estar associado à turma "Matemática - A" + + Cenário: Criar formulário a partir de template para múltiplas turmas (Happy Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu seleciono as turmas "TEC001 - Matemática - A" e "TEC002 - Português - B" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Formulários criados com sucesso" + E deve existir um formulário para a turma "Matemática - A" + E deve existir um formulário para a turma "Português - B" + E cada formulário deve conter as perguntas do template "Avaliação Padrão" + + Cenário: Tentar criar formulário sem selecionar template (Sad Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu não seleciono nenhum template + E eu seleciono as turmas "TEC001 - Matemática - A" + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Selecione um template para criar o formulário" + + Cenário: Tentar criar formulário sem selecionar turmas (Sad Path) + Quando eu acesso a página de criação de formulário a partir de template + E eu seleciono o template "Avaliação Padrão" + E eu não seleciono nenhuma turma + E eu clico em "Criar Formulário" + Então eu devo ver a mensagem "Selecione pelo menos uma turma" + + Cenário: Visualizar lista de templates disponíveis antes de criar + Quando eu acesso a página de criação de formulário a partir de template + Então eu devo ver a lista de templates disponíveis + E eu devo ver a lista de turmas do semestre "2026.1" disponíveis \ No newline at end of file diff --git a/features/definicao_senha.feature b/features/definicao_senha.feature new file mode 100644 index 0000000000..898b69805d --- /dev/null +++ b/features/definicao_senha.feature @@ -0,0 +1,32 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Definição de senha (primeiro acesso) + Eu, como usuário importado do SIGAA + Quero definir minha senha a partir de um link enviado por e-mail + A fim de efetivar meu cadastro e acessar o sistema + + Contexto: + Dado que o e-mail de usuário "usuario@teste.com" está cadastrado no sistema com senha indefinida + E um email de definição de senha é enviado para o email "usuario@teste.com" + + Cenário: Definir senha com sucesso (happy path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "Senha123" e confirmo a senha "Senha123" + E eu confirmo a definição de senha + Então vejo a mensagem "Senha definida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Definição de senha com confirmação diferente (sad path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "Senha123" e confirmo a senha "Senha321" + E eu confirmo a definição de senha + Então vejo a mensagem "Falha na definição de senha: confirmação não confere" + + Cenário: Definição de senha com senha inválida (sad path) + Quando eu acesso o link de definição de senha recebido por e-mail + E eu informo a nova senha "123" e confirmo a senha "123" + E eu confirmo a definição de senha + Então vejo a mensagem "Falha na definição de senha: senha inválida" diff --git a/features/edit_delete_template.feature b/features/edit_delete_template.feature new file mode 100644 index 0000000000..761af40070 --- /dev/null +++ b/features/edit_delete_template.feature @@ -0,0 +1,60 @@ +Feature: Edit and/or delete template + + Eu como Administrador + Quero editar e/ou deletar um template que eu criei sem afetar os formulários já criados + A fim de organizar os templates existentes + + Background: + Given I am authenticated as an "Administrador" + + # criar + Scenario: Edit a template title successfully(happy path) + + # setup inicial + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + And the template "Template Prova Matemática 2º semestre" has the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão desafio(1 ponto): | multipla_escolha | a: b: c: d: | + When I go to the "Meus Templates" page + And I follow "Editar" for "Template Prova Matemática 2º semestre" + + And I change the "titulo" to "Template Matemática Atualizado" + And I change the elemento "Questão desafio(1 ponto): " to "" + And I press "Salvar" + Then I should see a success message "Template atualizado com sucesso!" + And I should see "Template Matemática Atualizado" + But I should not see "Template Prova Matemática 2º semestre" + And the template "Template Matemática Atualizado" should have the following elementos: + | enunciado_elemento | tipo_campo | enunciado_campo | + | Questão 1(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 2(2 pontos): | multipla_escolha | a: b: c: d: | + | Questão 3(3 pontos): | multipla_escolha | a: b: c: d: | + | Questão 4(3 pontos): | multipla_escolha | a: b: c: d: | + + Scenario: Attempt to edit a template with a blank title(sad path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + When I go to the "Meus Templates" page + And I follow "Editar" for "Template Prova Matemática 2º semestre" + And I change the "titulo" to "" + And I press "Salvar" + Then I should see an error message "Título não pode ficar em branco!" + + # deletar + Scenario: Delete a template successfully(happy path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + When I go to the "Meus Templates" page + And I follow "Deletar" for "Template Prova Matemática 2º semestre" + And I confirm the deletion + Then I should see a success message "Template deletado com sucesso!" + And I should not see "Template Prova Matemática 2º semestre" + diff --git a/features/gerar_relatorio_csv.feature b/features/gerar_relatorio_csv.feature new file mode 100644 index 0000000000..1178162060 --- /dev/null +++ b/features/gerar_relatorio_csv.feature @@ -0,0 +1,26 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Download de resultados de formulário em CSV + Eu, como Administrador + Quero baixar um arquivo csv contendo os resultados de um formulário + A fim de avaliar o desempenho das turmas + + Contexto: + Dado que estou na página de Resultados + E vejo os formulários enviados para todas as turmas do meu departamento + E existe a "Turma A" de "Estruturas de Dados" que possui um formulário associado a ela + E este formulário já possui respostas enviadas pelos alunos + + Cenário: Baixar resultados do formulário com sucesso (happy path) + Quando eu sigo "Baixar Resultado" + Então o download do arquivo "formulario da Turma A de Estruturas de Dados" é iniciado + E o arquivo deve conter as colunas Usuário da Resposta, Data de Submissão e elementos do formulário + E o arquivo deve conter como linhas as respostas de cada usuário + + Cenário: Tentar baixar CSV de um formulário que não possui respostas (sad path) + Dado que a "Turma A" possui outro formulário + E este formulário não recebeu nenhuma resposta até o momento + Quando eu sigo "Baixar Resultado" + Então vejo a mensagem de erro "Falha na exportação: Este formulário ainda não possui respostas registradas." + E nenhum download de arquivo é iniciado \ No newline at end of file diff --git a/features/importar_dados_sigaa.feature b/features/importar_dados_sigaa.feature new file mode 100644 index 0000000000..829cb1212a --- /dev/null +++ b/features/importar_dados_sigaa.feature @@ -0,0 +1,29 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Importar dados do SIGAA + Eu, como Administrador + Quero importar dados de turmas, matérias e participantes do SIGAA (caso não existam na base de dados atual + A fim de alimentar a base de dados do sistema + P.S. utilizar os JSONs presentes no repositório + +Contexto: + Dado que estou na página de gerenciamento + E que os dados do SIGAA estão disponíveis para importação + +Cenário: Importação de dados do SIGAA (happy path) + Dado que os dados do SIGAA foram importados com sucesso + Então as turmas, matérias e participantes do SIGAA estão presentes no sistema + +Cenário: Importação de dados do SIGAA com falha (sad path) + Dado que eu tentei importar os dados do SIGAA mas ocorreu um erro + Então uma mensagem de erro é exibida informando que a importação falhou + +Cenário: Importação de dados do SIGAA com dados já existentes (sad path) + Dado que os dados do SIGAA já existem na base de dados do sistema + Então uma mensagem é exibida informando que os dados já foram importados e não serão importados novamente + +Cenário: Importação de dados do SIGAA com dados parcialmente existentes (sad path) + Dado que alguns dados do SIGAA já existem na base de dados do sistema + Então uma mensagem é exibida informando que alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso + diff --git a/features/login.feature b/features/login.feature new file mode 100644 index 0000000000..51c1f73be2 --- /dev/null +++ b/features/login.feature @@ -0,0 +1,48 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Login no sistema + Eu, como usuário do sistema + Quero acessar o sistema utilizando um e-mail ou matrícula cadastrada + A fim de responder formulários ou gerenciar o sistema + + Cenário: Login realizado com sucesso usando e-mail válido (happy path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Login realizado com sucesso usando matrícula válida (happy path) + Dado que minha matrícula "261067676" está cadastrada no sistema e senha "Senha123" + Quando eu tento realizar o login com matrícula "261067676" e a senha "Senha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Tentativa de login com a senha errada (sad path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123." + Então vejo a mensagem "Falha no login: senha incorreta" + E permaneço na página de login + + Cenário: Tentativa de login com usuário em branco (sad path) + Quando eu tento realizar o login sem informar meu email ou matrícula e com senha "Senha123" + Então vejo a mensagem "Falha no login: informe seu email ou matrícula" + E permaneço na página de login + + Cenário: Tentativa de login com senha em branco (sad path) + Quando eu tento realizar o login com email "usuario@teste.com" sem informar minha senha + Então vejo a mensagem "Falha no login: informe a sua senha" + E permaneço na página de login + + Cenário: Tentativa de login com usuário com cadastro não efetivado (sad path) + Dado que meu usuário está cadastrado com o email "usuario@teste.com" + Dado que minha senha para "usuario@teste.com" não está definida + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: usuário existente deve efetivar o seu cadastro por email" + E permaneço na página de login + + Cenário: Tentativa de login com usuário não cadastrado (sad path) + Dado que meu email "usuario@teste.com" não está cadastrado no sistema + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: usuário não encontrado" + E permaneço na página de login \ No newline at end of file diff --git a/features/redefinicao_senha.feature b/features/redefinicao_senha.feature new file mode 100644 index 0000000000..0f9d17ff33 --- /dev/null +++ b/features/redefinicao_senha.feature @@ -0,0 +1,63 @@ +# encoding : UTF-8 +# language: pt + +Funcionalidade: Redefinição de senha + Eu, como usuário cadastrado + Quero redefinir minha senha quando eu a esquecer + A fim de recuperar meu acesso ao sistema + + Contexto: + Dado que meu usuário está cadastrado com o email "usuario@teste.com" e senha "Senha123" + + Cenário: Solicitar redefinição de senha com sucesso (happy path) + Quando eu clico em "Esqueci minha senha" + E eu informo o email "usuario@teste.com" + E eu solicito a redefinição de senha + Então vejo a mensagem "Solicitação de redefinição de senha enviada." + E um email de redefinição de senha é enviado para o email "usuario@teste.com" + + Cenário: Redefinir senha com sucesso através do link (happy path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Senha redefinida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "NovaSenha123" + Então vejo a mensagem "Login realizado com sucesso." + E sou direcionado para a página inicial + + Cenário: Após redefinir a senha, a senha antiga deixa de funcionar (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Senha redefinida com sucesso." + Quando eu tento realizar o login com o email "usuario@teste.com" e a senha "Senha123" + Então vejo a mensagem "Falha no login: senha incorreta" + E permaneço na página de login + + Cenário: Solicitar redefinição para email não cadastrado (sad path) + Dado que meu email "naoexiste@teste.com" não está cadastrado no sistema + Quando eu clico em "Esqueci minha senha" + E eu informo o email "naoexiste@teste.com" + E eu solicito a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: usuário não encontrado" + + Cenário: Solicitar redefinição sem informar email (sad path) + Quando eu clico em "Esqueci minha senha" + E eu solicito a redefinição de senha sem informar meu email + Então vejo a mensagem "Falha na redefinição de senha: informe seu email" + + Cenário: Redefinição com confirmação diferente (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "NovaSenha123" e confirmo a senha "NovaSenha321" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: confirmação não confere" + + Cenário: Redefinição com senha inválida (sad path) + Dado que eu solicitei a redefinição de senha para o email "usuario@teste.com" + Quando eu acesso o link de redefinição de senha recebido por e-mail + E eu informo a nova senha "123" e confirmo a senha "123" + E eu confirmo a redefinição de senha + Então vejo a mensagem "Falha na redefinição de senha: senha inválida" diff --git a/features/responder_formulario.feature b/features/responder_formulario.feature new file mode 100644 index 0000000000..1b15384111 --- /dev/null +++ b/features/responder_formulario.feature @@ -0,0 +1,25 @@ +# language: pt + +Funcionalidade: Visualizar e responder formulário de avaliação + Como um aluno + Quero poder visualizar e responder a um formulário de avaliação + Para dar feedback sobre a turma ou disciplina + + Contexto: + Dado que eu estou logado como aluno + E existe um formulário ativo chamado "Avaliação de Turma 2026.1" + E eu estou na página de formulários disponíveis + + Cenário: Resposta completa ao formulário com sucesso (Happy Path) + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + Então eu devo visualizar os detalhes e perguntas pertinentes a ele + Quando eu respondo a pergunta "Como você avalia o professor?" com a opção "Ótimo" + E eu clico no botão "Enviar Avaliação" + Então eu devo ver a mensagem "Avaliação enviada com sucesso" + E o formulário "Avaliação de Turma 2026.1" não deve mais aparecer na minha lista de pendentes + + Cenário: Tentativa de envio com perguntas obrigatórias em branco (Sad Path) + Quando eu clico para responder o formulário "Avaliação de Turma 2026.1" + E eu deixo a pergunta obrigatória "Como você avalia o professor?" em branco + E eu clico no botão "Enviar Avaliação" + Então eu devo ver a mensagem "Por favor, responda todas as perguntas obrigatórias" diff --git a/features/step_definitions/.keep b/features/step_definitions/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/features/step_definitions/atualizar_dados_sigaa_steps.rb b/features/step_definitions/atualizar_dados_sigaa_steps.rb new file mode 100644 index 0000000000..d0cd1d5a9d --- /dev/null +++ b/features/step_definitions/atualizar_dados_sigaa_steps.rb @@ -0,0 +1,45 @@ +# Reutilizar o gerenciamento de paginas dos outros steps + +Dado('que os dados do SIGAA foram atualizados com sucesso') do + allow(SigaaImporter).to receive(:update_from_files).and_return("atualização realizada com sucesso") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que eu tentei atualizar os dados do SIGAA mas ocorreu um erro') do + allow(SigaaImporter).to receive(:update_from_files).and_return("falha") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que os dados do SIGAA já estão atualizados na base de dados do sistema') do + allow(SigaaImporter).to receive(:update_from_files).and_return("os dados do SIGAA já estão atualizados e não serão atualizados novamente") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que alguns dados do SIGAA já estão atualizados na base de dados do sistema') do + allow(SigaaImporter).to receive(:update_from_files).and_return("alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'atualizar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Então('as turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA') do + expect(page).to have_content('As turmas, matérias e participantes do SIGAA estão atualizados no sistema com os dados atuais do SIGAA.') +end + +Então('uma mensagem de erro é exibida informando que a atualização falhou') do + expect(page).to have_content('erro informando que a atualização falhou') +end + +Então('uma mensagem é exibida informando que os dados já estão atualizados e não serão atualizados novamente') do + expect(page).to have_content('os dados do SIGAA já estão atualizados e não serão atualizados novamente') +end + +Então('uma mensagem é exibida informando que alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso') do + expect(page).to have_content('alguns dados já estão atualizados e não serão atualizados novamente, mas os dados restantes serão atualizados com sucesso') +end diff --git a/features/step_definitions/cadastro_steps.rb b/features/step_definitions/cadastro_steps.rb new file mode 100644 index 0000000000..69416073bc --- /dev/null +++ b/features/step_definitions/cadastro_steps.rb @@ -0,0 +1,35 @@ +Dado('que estou na página de gerenciamento') do + departamento = Departamento.first || Departamento.create!(nome: "Ciência da Computação", codigo: "CIC") + @admin = Administrador.first || Administrador.create!( + nome: "Admin Teste", + matricula: "admin", + email: "admin@teste.com", + senha: "Senha123", + departamento: departamento + ) + + allow_any_instance_of(AdminController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) + end + + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, Administrador.find(controller.params[:admin_id])) + end + + visit admin_gerenciamento_path(@admin) +end + +Dado('que eu importei os dados do SIGAA com sucesso') do + # implementar a partir da feature de importar dados +end + +Então('um email de definição de senha é enviado para o email {string}') do |email| + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_definicao_senha! + + @email_destino = email + + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [ email ] } + expect(enviados).not_to be_empty +end diff --git a/features/step_definitions/criar_formulario_steps.rb b/features/step_definitions/criar_formulario_steps.rb new file mode 100644 index 0000000000..4df517218c --- /dev/null +++ b/features/step_definitions/criar_formulario_steps.rb @@ -0,0 +1,39 @@ +Dado('que eu estou logado como professor') do + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'professor@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' +end + +Dado('eu estou na página de criação de formulários') do + visit '/forms/new' +end + +Quando('eu preencho o título com {string}') do |titulo| + fill_in 'Título do Formulário', with: titulo +end + +Quando('eu deixo o título em branco') do + fill_in 'Título do Formulário', with: '' +end + +Quando('eu adiciono uma pergunta do tipo {string} com o texto {string}') do |tipo, texto| + # Ajustar a interação com os botões/selects dinâmicos na tela quando desenvolvidos + select tipo, from: 'Tipo de Pergunta' + fill_in 'Texto da Pergunta', with: texto + click_button 'Adicionar Pergunta' +end + +Quando('eu clico em {string}') do |nome_botao| + visit root_path unless page.has_button?(nome_botao) + click_button nome_botao +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('eu devo ver o formulário {string} na lista de formulários') do |nome_formulario| + expect(page).to have_content(nome_formulario) +end diff --git a/features/step_definitions/criar_formulario_template_steps.rb b/features/step_definitions/criar_formulario_template_steps.rb new file mode 100644 index 0000000000..d6fadcdfae --- /dev/null +++ b/features/step_definitions/criar_formulario_template_steps.rb @@ -0,0 +1,163 @@ +# frozen_string_literal: true + +# Step definitions for: Criar formulário baseado em template + +Dado('que eu estou logado como administrador') do + # TODO: Implementar autenticação como administrador + # administrador = Administrador.create!( + # nome: "Admin", + # email: "admin@ufpe.br", + # matricula: "admin123", + # departamento: Departamento.first + # ) + # administrador.enviar_email_definicao_senha! + # visit login_path + # fill_in 'login', with: administrador.email + # fill_in 'senha', with: 'senha_temporaria' + # click_button 'Entrar' +end + +Dado('que existe um template chamado {string} com as seguintes perguntas:') do |nome_template, table| + # table is a Cucumber::MultilineArgument::DataTable + # | Pergunta | Tipo | Opções | + # | Como você avalia o professor? | Múltipla Escolha | Ótimo, Bom, Regular, Ruim | + # | Qual seu nível de satisfação? | Escala | 1, 2, 3, 4, 5 | + # | Deixe seu comentário | Texto | | + # + # TODO: Implementar criação de template com elementos e campos + # @template = Template.create!(nome: nome_template) + # + # table.hashes.each do |row| + # elemento = @template.elementos.create!(enunciado: row['Pergunta'], ordem: @template.elementos.count + 1) + # + # case row['Tipo'] + # when 'Múltipla Escolha', 'Escala' + # row['Opções'].split(', ').each_with_index do |opcao, index| + # elemento.campos.create!(tipo_elemento: row['Tipo'], enunciado: opcao, ordem: index + 1) + # end + # when 'Texto' + # elemento.campos.create!(tipo_elemento: 'Texto', enunciado: '', ordem: 1) + # end + # end +end + +Dado('que existem as seguintes turmas no semestre {string}:') do |semestre, table| + # table is a Cucumber::MultilineArgument::DataTable + # | Código | Disciplina | Turma | + # | TEC001 | Matemática | A | + # | TEC002 | Português | B | + # | TEC003 | História | A | + # + # TODO: Implementar criação de turmas + # table.hashes.each do |row| + # departamento = Departamento.find_or_create_by!(nome: 'Departamento Padrão', codigo: 'DEP01') + # disciplina = Disciplina.find_or_create_by!( + # codigo: row['Código'], + # nome: row['Disciplina'], + # departamento: departamento + # ) + # Turma.find_or_create_by!( + # disciplina: disciplina, + # numero_da_turma: row['Turma'], + # semestre: semestre, + # horario: 'Seg 08:00-10:00' + # ) + # end + # @turmas_disponiveis = Turma.where(semestre: semestre) +end + +Quando('eu acesso a página de criação de formulário a partir de template') do + # TODO: Implementar rota para criação de formulário a partir de template + # visit new_formulario_from_template_path +end + +Quando('eu seleciono o template {string}') do |nome_template| + # TODO: Implementar seleção de template na interface + # select nome_template, from: 'template_id' +end + +Quando('eu não seleciono nenhum template') do + # TODO: Garantir que nenhum template está selecionado +end + +Quando('eu seleciono as turmas {string}') do |turmas_texto| + # TODO: Implementar seleção de turmas + # Exemplo de turmas_texto: "TEC001 - Matemática - A" + # turmas_texto.split(' e ').each do |turma_info| + # partes = turma_info.split(' - ') + # codigo = partes[0] + # nome_disciplina = partes[1] + # numero_turma = partes[2] + # + # disciplina = Disciplina.find_by!(codigo: codigo, nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # check "turma_ids_#{turma.id}" + # end +end + +Quando('eu não seleciono nenhuma turma') do + # TODO: Garantir que nenhuma turma está selecionada +end + +Quando('eu clico em {string}') do |nome_botao| + click_button nome_botao +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('o formulário deve conter as perguntas do template {string}') do |nome_template| + # TODO: Verificar se o formulário foi criado com os elementos copiados do template + # template = Template.find_by!(nome: nome_template) + # formulario = Formulario.last + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # formulario.elemento_forms.each_with_index do |ef, i| + # expect(ef.enunciado).to eq(template.elementos[i].enunciado) + # end +end + +Então('o formulário deve estar associado à turma {string}') do |nome_turma_info| + # TODO: Verificar associação com a turma correta + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.last.turma).to eq(turma) +end + +Então('eu devo ver a mensagem {string}') do |mensagem| + expect(page).to have_content(mensagem) +end + +Então('deve existir um formulário para a turma {string}') do |nome_turma_info| + # TODO: Verificar existência do formulário para a turma + # partes = nome_turma_info.split(' - ') + # nome_disciplina = partes[0] + # numero_turma = partes[1] + # disciplina = Disciplina.find_by!(nome: nome_disciplina) + # turma = Turma.find_by!(disciplina: disciplina, numero_da_turma: numero_turma) + # expect(Formulario.exists?(turma: turma)).to be true +end + +Então('cada formulário deve conter as perguntas do template {string}') do |nome_template| + # template = Template.find_by!(nome: nome_template) + # Formulario.all.each do |formulario| + # expect(formulario.elemento_forms.count).to eq(template.elementos.count) + # end +end + +Então('eu devo ver a lista de templates disponíveis') do + # TODO: Verificar se os templates são exibidos + # Template.all.each do |template| + # expect(page).to have_content(template.nome) + # end +end + +Então('eu devo ver a lista de turmas do semestre {string} disponíveis') do |semestre| + # TODO: Verificar se as turmas do semestre são exibidas + # Turma.where(semestre: semestre).each do |turma| + # expect(page).to have_content(turma.disciplina.nome) + # end +end diff --git a/features/step_definitions/exportar_csv_steps.rb b/features/step_definitions/exportar_csv_steps.rb new file mode 100644 index 0000000000..4687e68e13 --- /dev/null +++ b/features/step_definitions/exportar_csv_steps.rb @@ -0,0 +1,204 @@ +# encoding: UTF-8 + +require 'csv' + +Dado("que estou na página de Resultados") do + @departamento = Departamento.create!( + codigo: "DEP01", + nome: "Departamento de Computação" + ) + + @admin = Administrador.create!( + matricula: "ADM001", + nome: "Admin Teste", + email: "admin@teste.com", + departamento: @departamento + ) + + # Reutiliza o step de login já existente nos steps de autenticação + step 'que meu usuário está cadastrado com o email "admin@teste.com" e senha "senha123"' + step 'eu tento realizar o login com o email "admin@teste.com" e a senha "senha123"' + + visit admin_resultados_path +end + +Dado("vejo os formulários enviados para todas as turmas do meu departamento") do + expect(page).to have_current_path(admin_resultados_path) +end + +Dado("existe a {string} de {string} que possui um formulário associado a ela") do |nome_turma, nome_disciplina| + @disciplina = Disciplina.create!( + codigo: "ED001", + nome: nome_disciplina, + departamento: @departamento + ) + + @turma = Turma.create!( + numero_da_turma: nome_turma, + semestre: "2024.1", + horario: "SEG 08:00-10:00", + disciplina: @disciplina + ) + + @formulario = Formulario.create!(turma: @turma) + + @elemento1 = ElementoForm.create!( + ordem: 1, + enunciado: "Como você avalia o professor?", + formulario: @formulario + ) + + @elemento2 = ElementoForm.create!( + ordem: 2, + enunciado: "Como você avalia a disciplina?", + formulario: @formulario + ) +end + +Dado("este formulário já possui respostas enviadas pelos alunos") do + @curso_aluno = Curso.create!( + codigo: "CC01", + nome: "Ciência da Computação", + departamento: @departamento + ) + + @aluno = Discente.create!( + matricula: "ALU001", + nome: "Aluno Teste", + email: "aluno@teste.com", + curso: @curso_aluno, + departamento: @departamento + ) + + @resposta = RespostaForm.create!( + formulario: @formulario, + usuario: @aluno, + data_submissao: Date.today + ) + + @template = Template.new(nome: "Template Padrão") + elemento_base = @template.elementos.build(ordem: 1, enunciado: "Avaliação") + elemento_base.campos.build(ordem: 1, enunciado: "Muito bom", tipo_elemento: "Múltipla Escolha") + elemento_base.campos.build(ordem: 2, enunciado: "Excelente", tipo_elemento: "Múltipla Escolha") + @template.save! + + [@elemento1, @elemento2].each do |ef| + elemento_base.campos.each do |campo_base| + CampoForm.find_or_create_by!(enunciado: campo_base.enunciado, elemento_form: ef) do |cf| + cf.ordem = campo_base.ordem + end + end + end + + { + @elemento1 => "Muito bom", + @elemento2 => "Excelente" + }.each do |ef, texto| + cf = ef.campo_forms.find_by!(enunciado: texto) + + RespostaElem.create!( + texto_resposta: texto, + resposta_form: @resposta, + elemento_form: ef, + campo_form: cf + ) + end + + visit admin_resultados_path +end + + +# Happy Path + +Quando("eu sigo {string}") do |link| + formulario_alvo = defined?(@formulario_vazio) ? @formulario_vazio : @formulario + find(:link, link, href: /#{formulario_alvo.id}/).click +end + +Então("o download do arquivo {string} é iniciado") do |_nome_ignorado| + num_turma = @formulario.turma.numero_da_turma.parameterize(separator: '_') + nome_materia = @formulario.turma.disciplina.nome.parameterize(separator: '_') + nome_esperado = "formulario_#{@formulario.id}_turma_#{num_turma}_#{nome_materia}" + + content_disposition = page.response_headers["Content-Disposition"] + + expect(content_disposition).to be_present, + "Esperava um header Content-Disposition indicando download, mas não havia nenhum." + + expect(content_disposition).to include("attachment"), + "Esperava 'attachment' no Content-Disposition, mas foi: #{content_disposition}" + + expect(content_disposition).to include(nome_esperado), + "Esperava '#{nome_esperado}' no nome do arquivo, " \ + "mas o header foi: #{content_disposition}" +end + +Então("o arquivo deve conter as colunas Usuário da Resposta, Data de Submissão e elementos do formulário") do + csv_content = CSV.parse(page.body) + cabecalho = csv_content.first + + expect(cabecalho).to include("Usuário da Resposta"), + "Esperava a coluna 'Usuário da Resposta' no cabeçalho, mas foi: #{cabecalho.inspect}" + + expect(cabecalho).to include("Data de Submissão"), + "Esperava a coluna 'Data de Submissão' no cabeçalho, mas foi: #{cabecalho.inspect}" + + ElementoForm.where(formulario_id: @formulario.id).order(:ordem).each do |elem| + expect(cabecalho).to include(elem.enunciado), + "Esperava a coluna '#{elem.enunciado}' no cabeçalho, mas foi: #{cabecalho.inspect}" + end +end + +Então("o arquivo deve conter como linhas as respostas de cada usuário") do + csv_content = CSV.parse(page.body) + + linhas_de_dados = csv_content[1..] + + expect(linhas_de_dados).not_to be_empty, + "Esperava pelo menos uma linha de dados no CSV, mas o arquivo só possui o cabeçalho." + + nomes_nas_linhas = linhas_de_dados.map(&:first) + expect(nomes_nas_linhas).to include(@aluno.nome), + "Esperava encontrar '#{@aluno.nome}' nas linhas de dados, mas encontrei: #{nomes_nas_linhas.inspect}" + + RespostaElem.where(resposta_form_id: @resposta.id).each do |re| + conteudo_csv = linhas_de_dados.flatten + expect(conteudo_csv).to include(re.texto_resposta), + "Esperava encontrar a resposta '#{re.texto_resposta}' no CSV." + end +end + +# Sad Path + +Dado("que a {string} possui outro formulário") do |nome_turma| + @turma_sad = Turma.find_by(numero_da_turma: nome_turma) || @turma + + @formulario_vazio = Formulario.create!(turma: @turma_sad) + + ElementoForm.create!( + ordem: 1, + enunciado: "Pergunta sem respostas", + formulario: @formulario_vazio + ) +end + +Dado("este formulário não recebeu nenhuma resposta até o momento") do + expect( + RespostaForm.where(formulario_id: @formulario_vazio.id).count + ).to eq(0), "Esperava 0 respostas para o formulário vazio, mas havia algumas." + + visit admin_resultados_path +end + +Então("vejo a mensagem de erro {string}") do |mensagem_esperada| + expect(page).to have_content(mensagem_esperada), + "Esperava ver '#{mensagem_esperada}' na página, mas não encontrei." +end + +Então("nenhum download de arquivo é iniciado") do + content_disposition = page.response_headers["Content-Disposition"] + + expect(content_disposition).to be_nil.or( + satisfy { |cd| !cd.to_s.include?("attachment") } + ), "Não esperava um header de download 'attachment', mas encontrei: #{content_disposition}" +end diff --git a/features/step_definitions/importar_dados_sigaa_steps.rb b/features/step_definitions/importar_dados_sigaa_steps.rb new file mode 100644 index 0000000000..f2fa158a39 --- /dev/null +++ b/features/step_definitions/importar_dados_sigaa_steps.rb @@ -0,0 +1,48 @@ + +Dado('que os dados do SIGAA estão disponíveis para importação') do + # Por padrão, o SigaaImporter importará os dados do arquivo JSON enviado, então não é necessário configurar nada aqui. +end + +Dado('que os dados do SIGAA foram importados com sucesso') do + allow(SigaaImporter).to receive(:import_from_files).and_return("importação realizada com sucesso") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que eu tentei importar os dados do SIGAA mas ocorreu um erro') do + allow(SigaaImporter).to receive(:import_from_files).and_return("a importação falhou") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que os dados do SIGAA já existem na base de dados do sistema') do + allow(SigaaImporter).to receive(:import_from_files).and_return("os dados já existem e não foram duplicados") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Dado('que alguns dados do SIGAA já existem na base de dados do sistema') do + allow(SigaaImporter).to receive(:import_from_files).and_return("alguns dados já foram importados e não serão importados novamente") + arquivo = Rack::Test::UploadedFile.new(Rails.root.join("classes.json"), "application/json") + page.driver.post(admin_sincronizar_sigaa_path(@admin), { acao: 'importar', arquivo_sigaa: arquivo }) + visit admin_gerenciamento_path(@admin) +end + +Então('as turmas, matérias e participantes do SIGAA estão presentes no sistema') do + expect(page).to have_content('As turmas, matérias e participantes do SIGAA estão presentes no sistema') +end + +Então('uma mensagem de erro é exibida informando que a importação falhou') do + expect(page).to have_content('erro informando que a importação falhou') +end + +Então('uma mensagem é exibida informando que os dados já foram importados e não serão importados novamente') do + expect(page).to have_content('os dados do SIGAA já existem na base de dados do sistema e não serão importados novamente') +end + +Então('uma mensagem é exibida informando que alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso') do + expect(page).to have_content('alguns dados já foram importados e não serão importados novamente, mas os dados restantes serão importados com sucesso') +end diff --git a/features/step_definitions/login_steps.rb b/features/step_definitions/login_steps.rb new file mode 100644 index 0000000000..7cdcae1677 --- /dev/null +++ b/features/step_definitions/login_steps.rb @@ -0,0 +1,71 @@ +Dado('que meu usuário está cadastrado com o email {string}') do |email| + Usuario.find_or_create_by!(email: email) do |u| + u.matricula = "#{rand(100000..999999)}" + u.nome = "Usuário Teste" + end +end + +Dado('que meu email {string} não está cadastrado no sistema') do |email| + Usuario.where(email: email).delete_all +end + +Dado('que meu usuário está cadastrado com o email {string} e senha {string}') do |email, senha| + usuario = Usuario.find_or_initialize_by(email: email) + usuario.matricula ||= "#{rand(100000..999999)}" + usuario.nome ||= "Usuário Teste" + usuario.senha = senha + usuario.senha_confirmation = senha + usuario.save! +end + +Dado('que minha matrícula {string} está cadastrada no sistema e senha {string}') do |matricula, senha| + usuario = Usuario.find_or_initialize_by(matricula: matricula) + usuario.email ||= "#{matricula}@teste.com" + usuario.nome ||= "Usuário Teste" + usuario.senha = senha + usuario.senha_confirmation = senha + usuario.save! +end + +Dado('que minha senha para {string} não está definida') do |email| + usuario = Usuario.find_by!(email: email) + usuario.update!(senha_hash: nil) +end + +Quando('eu tento realizar o login com o email {string} e a senha {string}') do |email_usuario, senha_usuario| + visit root_path + fill_in "login", with: email_usuario + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login com matrícula {string} e a senha {string}') do |matricula_usuario, senha_usuario| + visit root_path + fill_in "login", with: matricula_usuario + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login sem informar meu email ou matrícula e com senha {string}') do |senha_usuario| + visit root_path + fill_in "senha", with: senha_usuario + click_button "Entrar" +end + +Quando('eu tento realizar o login com email {string} sem informar minha senha') do |email_usuario| + visit root_path + fill_in "login", with: email_usuario + click_button "Entrar" +end + +Então('vejo a mensagem {string}') do |string| + expect(page).to have_content(string) +end + +Então('permaneço na página de login') do + expect(page).to have_current_path(root_path) +end + +Então('sou direcionado para a página inicial') do + expect(page).to have_current_path(inicio_path) +end diff --git a/features/step_definitions/responder_formulario_steps.rb b/features/step_definitions/responder_formulario_steps.rb new file mode 100644 index 0000000000..eebcbd09dd --- /dev/null +++ b/features/step_definitions/responder_formulario_steps.rb @@ -0,0 +1,43 @@ +Dado('que eu estou logado como aluno') do + # Implementar quando definir models e autenticação + # visit '/login' + # fill_in 'Email', with: 'aluno@ufpe.br' + # fill_in 'Senha', with: 'senha123' + # click_button 'Entrar' +end + +Dado('existe um formulário ativo chamado {string}') do |nome_formulario| + # Implementar a criação desse registro (Form/Evaluation) no banco usando Factory/ActiveRecord +end + +Dado('eu estou na página de formulários disponíveis') do + visit '/forms/pending' +end + +Quando('eu clico para responder o formulário {string}') do |nome_formulario| + # Ajustar seletor dependendo da interface, por exemplo, achar o escopo do texto ou tr + click_link "Responder" +end + +Então('eu devo visualizar os detalhes e perguntas pertinentes a ele') do + # Assumindo que a classe .form-question existirá na view + expect(page).to have_selector('.form-question') +end + +Quando('eu respondo a pergunta {string} com a opção {string}') do |pergunta, opcao| + # Ajustar conformidade de input visual (radio, select, text) + choose opcao +end + +Quando('eu deixo a pergunta obrigatória {string} em branco') do |pergunta| + # O comportamento de deixar em branco pode ser simplesmente não preencher, logo, nenhum click extra. +end + +Quando('eu clico no botão {string}') do |nome_botao| + click_button nome_botao +end + +Então('o formulário {string} não deve mais aparecer na minha lista de pendentes') do |nome_formulario| + visit '/forms/pending' + expect(page).not_to have_content(nome_formulario) +end diff --git a/features/step_definitions/senha_steps.rb b/features/step_definitions/senha_steps.rb new file mode 100644 index 0000000000..e360e4907b --- /dev/null +++ b/features/step_definitions/senha_steps.rb @@ -0,0 +1,76 @@ +Dado('que o e-mail de usuário {string} está cadastrado no sistema com senha indefinida') do |email| + usuario = Usuario.find_or_initialize_by(email: email) + usuario.matricula ||= "#{rand(100000..999999)}" + usuario.nome ||= "Usuário Teste" + usuario.senha_hash = nil + usuario.save! +end + +Quando('eu acesso o link de definição de senha recebido por e-mail') do + email_destino = @email_destino || raise("Email de destino não definido nos steps") + + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [ email_destino ] } + raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? + + corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded + url = corpo[%r{https?://\S+}] + raise("Não encontrei URL no email") if url.nil? + + visit url +end + +Quando('eu informo a nova senha {string} e confirmo a senha {string}') do |senha, confirmacao| + fill_in "senha", with: senha + fill_in "senha_confirmation", with: confirmacao +end + +Quando('eu confirmo a definição de senha') do + click_button "Definir senha" +end + +Quando('eu informo o email {string}') do |email| + fill_in "email", with: email +end + +Quando('eu solicito a redefinição de senha') do + click_button "Solicitar redefinição" +end + +Quando('eu solicito a redefinição de senha sem informar meu email') do + click_button "Solicitar redefinição" +end + +Então('um email de redefinição de senha é enviado para o email {string}') do |email| + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_redefinicao_senha! + + @email_destino = email + + enviados = ActionMailer::Base.deliveries.select { |m| m.to == [ email ] } + expect(enviados).not_to be_empty +end + +Dado('que eu solicitei a redefinição de senha para o email {string}') do |email| + usuario = Usuario.find_by!(email: email) + ActionMailer::Base.deliveries.clear + usuario.enviar_email_redefinicao_senha! + @email_destino = email +end + +Quando('eu acesso o link de redefinição de senha recebido por e-mail') do + email_destino = @email_destino || raise("Email de destino não definido nos steps") + + mensagem = ActionMailer::Base.deliveries.reverse.find { |m| m.to == [ email_destino ] } + raise("Nenhum email enviado para #{email_destino}") if mensagem.nil? + + corpo = mensagem.text_part&.body&.decoded || mensagem.html_part&.body&.decoded || mensagem.body.decoded + url = corpo[%r{https?://\S+}] + raise("Não encontrei URL no email") if url.nil? + + visit url +end + +Quando('eu confirmo a redefinição de senha') do + click_button "Redefinir senha" +end diff --git a/features/step_definitions/template_steps.rb b/features/step_definitions/template_steps.rb new file mode 100644 index 0000000000..4a0a1928ae --- /dev/null +++ b/features/step_definitions/template_steps.rb @@ -0,0 +1,173 @@ +Given(/^I [aA]m authenticated as an "([^"]*)"$/) do |role| + depto = Departamento.find_or_create_by!(nome: 'Departamento', codigo: 'TST') + + @admin = Administrador.find_or_create_by!(email: 'admin@unb.br') do |u| + u.senha_hash = '123456' + u.nome = 'Admin' + u.matricula = '123456789' + u.departamento = depto + end + + allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(@admin) + + allow_any_instance_of(TemplatesController).to receive(:set_admin) do |controller| + controller.instance_variable_set(:@admin, @admin) + end +end + +Given('I Am on the home page') do + visit inicio_path +end + +Given('I go to the {string} page') do |page| + admin = Administrador.first + visit admin_templates_path(admin) if page == "Meus Templates" +end + +Given('I am on the {string} page') do |page_name| + expect(page).to have_content("Nome do template:") +end + +When('I follow {string}') do |link| + if link == "Adicionar novo template" + admin = Administrador.first + visit new_admin_template_path(admin) + else + click_link_or_button(link) + end +end + +When('I follow {string} for {string}') do |acao, template_nome| + card = find('.card', text: template_nome) + card.find("[aria-label='#{acao}']").click +end + +When('I press {string}') do |botao| + if page.has_button?('Criar') + click_button 'Criar' + else + click_button 'Salvar' + end +end + +When('I confirm the deletion') do +end + +Given('I have added the template') do |table| + dados = table.rows_hash + valor = dados['titulo'].gsub(/^"|"$/, '') + fill_in "Nome do template:", with: valor +end + +Given('I add the following elementos:') do |table| + table.hashes.each_with_index do |row, index| + find('.add-question-btn', visible: :all).click if index > 0 + + within all('.question-block:not(.deleted-block)').last do + find('.figma-input-line-full[placeholder="Digite a pergunta..."]').set(row['enunciado_elemento']) + + tipo = row['tipo_campo'] == 'multipla_escolha' ? 'Múltipla Escolha' : 'Texto' + find('.select-tipo').find("option[value='#{tipo}']").select_option + + if tipo == 'Múltipla Escolha' + opcoes = row['enunciado_campo'].split(':').map(&:strip).reject(&:empty?) + opcoes.each_with_index do |opcao, opt_idx| + find('.btn-add-option').click if opt_idx > 0 + all('.option-row:not(.deleted-option) input.figma-input-line-full').last.set(opcao) + end + end + end + end +end + +Given('I dont add elementos') do + find('input.destroy-question-input', visible: :hidden).set('1') +end + +When('I change the {string} to {string}') do |campo, valor| + fill_in "Nome do template:", with: valor if campo == "titulo" +end + +When('I change the elemento {string} to {string}') do |antigo, novo| + if novo.empty? + input = find("input.figma-input-line-full[value='#{antigo.strip}']") + bloco = input.ancestor('.question-block') + within(bloco) do + find('input.destroy-question-input', visible: :hidden).set('1') + end + else + input = find("input.figma-input-line-full[value='#{antigo.strip}']") + input.set(novo) + end +end + +Then('I should see a success message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('I should see an error message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('the template {string} should be listed in my templates') do |nome| + expect(page).to have_content(nome) +end + +Then('I should see {string}') do |texto| + expect(page).to have_content(texto) +end + +Then('I should not see {string}') do |texto| + expect(page).not_to have_content(texto) +end + +Then('I should see the message {string}') do |msg| + expect(page).to have_content(msg) +end + +Then('I should see options to {string} and {string} for each template') do |acao1, acao2| + expect(page).to have_selector("[aria-label='#{acao1}']") + expect(page).to have_selector("[aria-label='#{acao2}']") +end + +Then('I should see a button {string}') do |botao| + expect(page).to have_selector("a, button", text: botao) +end + +Then('the template {string} should have the following elementos:') do |nome, table| + template = Template.find_by(nome: nome) + expect(template.elementos.count).to eq(table.hashes.count) +end + +Given('I have the following templates saved:') do |table| + admin = Administrador.first + table.hashes.each do |row| + template = Template.new(nome: row['titulo'], administrador: admin) + elemento = template.elementos.build(enunciado: "Questão Fantasma", ordem: 1) + elemento.campos.build(tipo_elemento: "Texto", ordem: 1) + template.save! + end +end + +Given('the template {string} has the following elementos:') do |nome, table| + template = Template.find_by(nome: nome) + template.elementos.destroy_all # Limpa a fantasma + + table.hashes.each_with_index do |row, index| + tipo = row['tipo_campo'] == 'multipla_escolha' ? 'Múltipla Escolha' : 'Texto' + elemento = template.elementos.create!(enunciado: row['enunciado_elemento'], ordem: index + 1) + + if tipo == 'Múltipla Escolha' + opcoes = row['enunciado_campo'].split(':').map(&:strip).reject(&:empty?) + opcoes.each_with_index do |opcao, opt_idx| + elemento.campos.create!(tipo_elemento: tipo, enunciado: opcao, ordem: opt_idx + 1) + end + else + elemento.campos.create!(tipo_elemento: tipo, ordem: 1) + end + end +end + +Given('I have no templates saved') do + Template.destroy_all +end diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 0000000000..b475ecd447 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,66 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +require 'cucumber/rails' + +# By default, any exception happening in your Rails application will bubble up +# to Cucumber so that your scenario will fail. This is a different from how +# your application behaves in the production environment, where an error page will +# be rendered instead. +# +# Sometimes we want to override this default behaviour and allow Rails to rescue +# exceptions and display an error page (just like when the app is running in production). +# Typical scenarios where you want to do this is when you test your error pages. +# There are two ways to allow Rails to rescue exceptions: +# +# 1) Tag your scenario (or feature) with @allow-rescue +# +# 2) Set the value below to true. Beware that doing this globally is not +# recommended as it will mask a lot of errors for you! +# +ActionController::Base.allow_rescue = false + +# Remove/comment out the lines below if your app doesn't have a database. +# For some databases (like MongoDB and CouchDB) you may need to use :truncation instead. +begin + DatabaseCleaner.strategy = :transaction +rescue NameError + raise "You need to add database_cleaner to your Gemfile (in the :test group) if you wish to use it." +end + +# You may also want to configure DatabaseCleaner to use different strategies for certain features and scenarios. +# See the DatabaseCleaner documentation for details. Example: +# +# Before('@no-txn,@selenium,@culerity,@celerity,@javascript') do +# # { except: [:widgets] } may not do what you expect here +# # as Cucumber::Rails::Database.javascript_strategy overrides +# # this setting. +# DatabaseCleaner.strategy = :truncation +# end +# +# Before('not @no-txn', 'not @selenium', 'not @culerity', 'not @celerity', 'not @javascript') do +# DatabaseCleaner.strategy = :transaction +# end +# + +# Possible values are :truncation and :transaction +# The :transaction strategy is faster, but might give you threading problems. +# See https://github.com/cucumber/cucumber-rails/blob/master/features/choose_javascript_database_strategy.feature +Cucumber::Rails::Database.javascript_strategy = :truncation + +# Make RSpec mocks available in Cucumber steps (allow_any_instance_of, allow, etc.) +require 'rspec/mocks' +World(RSpec::Mocks::ExampleMethods) + +Before do + RSpec::Mocks.setup +end + +After do + RSpec::Mocks.verify + RSpec::Mocks.teardown +end diff --git a/features/view_template.feature b/features/view_template.feature new file mode 100644 index 0000000000..27a1f82f20 --- /dev/null +++ b/features/view_template.feature @@ -0,0 +1,24 @@ +Feature: View Template + + Eu como Administrador + Quero visualizar os templates criados + A fim de poder editar e/ou deletar um template que eu criei + + Background: + Given I am authenticated as an "Administrador" + + Scenario: View template list successfully(happy path) + Given I have the following templates saved: + | titulo | + | Template Prova Matemática 2º semestre | + | Template Prova Português 2º semestre | + When I go to the "Meus Templates" page + Then I should see "Template Prova Matemática 2º semestre" + And I should see "Template Prova Português 2º semestre" + And I should see options to "Editar" and "Deletar" for each template + + Scenario: View empty template list(sad path) + Given I have no templates saved + When I go to the "Meus Templates" page + Then I should see the message "Nenhum template encontrado." + And I should see a button "Criar novo template" \ No newline at end of file diff --git a/lib/tasks/.keep b/lib/tasks/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/lib/tasks/cucumber.rake b/lib/tasks/cucumber.rake new file mode 100644 index 0000000000..b790c4d483 --- /dev/null +++ b/lib/tasks/cucumber.rake @@ -0,0 +1,68 @@ +# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril. +# It is recommended to regenerate this file in the future when you upgrade to a +# newer version of cucumber-rails. Consider adding your own code to a new file +# instead of editing this one. Cucumber will automatically load all features/**/*.rb +# files. + + +unless ARGV.any? { |a| a =~ /^gems/ } # Don't load anything when running the gems:* tasks + +vendored_cucumber_bin = Dir["#{Rails.root}/vendor/{gems,plugins}/cucumber*/bin/cucumber"].first +$LOAD_PATH.unshift(File.dirname(vendored_cucumber_bin) + "/../lib") unless vendored_cucumber_bin.nil? + +begin + require "cucumber/rake/task" + + namespace :cucumber do + Cucumber::Rake::Task.new({ ok: "test:prepare" }, "Run features that should pass") do |t| + t.binary = vendored_cucumber_bin # If nil, the gem's binary is used. + t.fork = true # You may get faster startup if you set this to false + t.profile = "default" + end + + Cucumber::Rake::Task.new({ wip: "test:prepare" }, "Run features that are being worked on") do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = "wip" + end + + Cucumber::Rake::Task.new({ rerun: "test:prepare" }, "Record failing features and run only them if any exist") do |t| + t.binary = vendored_cucumber_bin + t.fork = true # You may get faster startup if you set this to false + t.profile = "rerun" + end + + desc "Run all features" + task all: [ :ok, :wip ] + + task :statsetup do + require "rails/code_statistics" + ::STATS_DIRECTORIES << %w[Cucumber\ features features] if File.exist?("features") + ::CodeStatistics::TEST_TYPES << "Cucumber features" if File.exist?("features") + end + end + + desc "Alias for cucumber:ok" + task cucumber: "cucumber:ok" + + task default: :cucumber + + task features: :cucumber do + STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***" + end + + # In case we don't have the generic Rails test:prepare hook, append a no-op task that we can depend upon. + task "test:prepare" do + end + + task stats: "cucumber:statsetup" + + +rescue LoadError + desc "cucumber rake task not available (cucumber not installed)" + task :cucumber do + abort "Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin" + end +end + +end diff --git a/log/.keep b/log/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/public/400.html b/public/400.html new file mode 100644 index 0000000000..640de03397 --- /dev/null +++ b/public/400.html @@ -0,0 +1,135 @@ + + + + + + + The server cannot process the request due to a client error (400 Bad Request) + + + + + + + + + + + + + +
+
+ +
+
+

The server cannot process the request due to a client error. Please check the request and try again. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/404.html b/public/404.html new file mode 100644 index 0000000000..d7f0f14222 --- /dev/null +++ b/public/404.html @@ -0,0 +1,135 @@ + + + + + + + The page you were looking for doesn't exist (404 Not found) + + + + + + + + + + + + + +
+
+ +
+
+

The page you were looking for doesn't exist. You may have mistyped the address or the page may have moved. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/406-unsupported-browser.html b/public/406-unsupported-browser.html new file mode 100644 index 0000000000..43d2811e8c --- /dev/null +++ b/public/406-unsupported-browser.html @@ -0,0 +1,135 @@ + + + + + + + Your browser is not supported (406 Not Acceptable) + + + + + + + + + + + + + +
+
+ +
+
+

Your browser is not supported.
Please upgrade your browser to continue.

+
+
+ + + + diff --git a/public/422.html b/public/422.html new file mode 100644 index 0000000000..f12fb4aa17 --- /dev/null +++ b/public/422.html @@ -0,0 +1,135 @@ + + + + + + + The change you wanted was rejected (422 Unprocessable Entity) + + + + + + + + + + + + + +
+
+ +
+
+

The change you wanted was rejected. Maybe you tried to change something you didn't have access to. If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/500.html b/public/500.html new file mode 100644 index 0000000000..e4eb18a759 --- /dev/null +++ b/public/500.html @@ -0,0 +1,135 @@ + + + + + + + We're sorry, but something went wrong (500 Internal Server Error) + + + + + + + + + + + + + +
+
+ +
+
+

We're sorry, but something went wrong.
If you're the application owner check the logs for more information.

+
+
+ + + + diff --git a/public/icon.png b/public/icon.png new file mode 100644 index 0000000000..c4c9dbfbbd Binary files /dev/null and b/public/icon.png differ diff --git a/public/icon.svg b/public/icon.svg new file mode 100644 index 0000000000..04b34bf83f --- /dev/null +++ b/public/icon.svg @@ -0,0 +1,3 @@ + + + diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000000..c19f78ab68 --- /dev/null +++ b/public/robots.txt @@ -0,0 +1 @@ +# See https://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file diff --git a/script/.keep b/script/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/spec/models/administrador_spec.rb b/spec/models/administrador_spec.rb new file mode 100644 index 0000000000..7ae82480c1 --- /dev/null +++ b/spec/models/administrador_spec.rb @@ -0,0 +1,40 @@ +require 'rails_helper' + +RSpec.describe Administrador, type: :model do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + + context "validações de criação" do + it "é válido com todos os atributos obrigatórios" do + admin = Administrador.new( + nome: "Admin Teste", + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: departamento + ) + expect(admin).to be_valid + end + + it "não é válido sem um nome" do + admin = Administrador.new( + nome: nil, + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: departamento + ) + expect(admin).not_to be_valid + end + + it "não é válido sem um departamento associado" do + admin = Administrador.new( + nome: "Admin Teste", + matricula: "admin123", + email: "admin@unb.br", + senha: "Senha123", + departamento: nil + ) + expect(admin).not_to be_valid + end + end +end diff --git a/spec/models/campo_form_spec.rb b/spec/models/campo_form_spec.rb new file mode 100644 index 0000000000..05d3574c3d --- /dev/null +++ b/spec/models/campo_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CampoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/campo_spec.rb b/spec/models/campo_spec.rb new file mode 100644 index 0000000000..6618006be8 --- /dev/null +++ b/spec/models/campo_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Campo, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/curso_spec.rb b/spec/models/curso_spec.rb new file mode 100644 index 0000000000..4e29152a4a --- /dev/null +++ b/spec/models/curso_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Curso, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/departamento_spec.rb b/spec/models/departamento_spec.rb new file mode 100644 index 0000000000..0a0d313f9c --- /dev/null +++ b/spec/models/departamento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Departamento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/disciplina_spec.rb b/spec/models/disciplina_spec.rb new file mode 100644 index 0000000000..17de7443da --- /dev/null +++ b/spec/models/disciplina_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Disciplina, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_form_spec.rb b/spec/models/elemento_form_spec.rb new file mode 100644 index 0000000000..2a8ad23d78 --- /dev/null +++ b/spec/models/elemento_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ElementoForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/elemento_spec.rb b/spec/models/elemento_spec.rb new file mode 100644 index 0000000000..fd36adff7a --- /dev/null +++ b/spec/models/elemento_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Elemento, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/formulario_spec.rb b/spec/models/formulario_spec.rb new file mode 100644 index 0000000000..2318f88769 --- /dev/null +++ b/spec/models/formulario_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Formulario, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_elem_spec.rb b/spec/models/resposta_elem_spec.rb new file mode 100644 index 0000000000..f466723e9d --- /dev/null +++ b/spec/models/resposta_elem_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaElem, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/resposta_form_spec.rb b/spec/models/resposta_form_spec.rb new file mode 100644 index 0000000000..16bb6683d4 --- /dev/null +++ b/spec/models/resposta_form_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe RespostaForm, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/template_spec.rb b/spec/models/template_spec.rb new file mode 100644 index 0000000000..13e107ef8c --- /dev/null +++ b/spec/models/template_spec.rb @@ -0,0 +1,42 @@ +require 'rails_helper' + +RSpec.describe Template, type: :model do + let(:departamento) { Departamento.find_or_create_by!(nome: "Ciência da Computação", codigo: "CIC") } + let(:admin) do + Administrador.find_or_create_by!(email: "admin_template@unb.br") do |u| + u.nome = "Admin Template" + u.matricula = "78910" + u.senha = "Senha123" + u.departamento = departamento + end + end + + context "validações de criação e relacionamento" do + it "é válido com nome, um administrador e pelo menos um elemento" do + template = Template.new(nome: "Avaliação da Turma", administrador: admin) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).to be_valid + end + + it "não é válido sem um nome (título)" do + template = Template.new(nome: "", administrador: admin) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).not_to be_valid + end + + it "não é válido sem um administrador associado" do + template = Template.new(nome: "Formulário Fantasma", administrador: nil) + template.elementos.build(enunciado: "Questão 1", ordem: 1) + + expect(template).not_to be_valid + end + + it "não é válido se não possuir nenhum elemento (questão)" do + template = Template.new(nome: "Formulário Vazio", administrador: admin) + + expect(template).not_to be_valid + end + end +end diff --git a/spec/models/turma_spec.rb b/spec/models/turma_spec.rb new file mode 100644 index 0000000000..b7629b1e16 --- /dev/null +++ b/spec/models/turma_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Turma, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/usuario_spec.rb b/spec/models/usuario_spec.rb new file mode 100644 index 0000000000..12591f4841 --- /dev/null +++ b/spec/models/usuario_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Usuario, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb new file mode 100644 index 0000000000..ef75d46770 --- /dev/null +++ b/spec/rails_helper.rb @@ -0,0 +1,72 @@ +# This file is copied to spec/ when you run 'rails generate rspec:install' +require 'spec_helper' +ENV['RAILS_ENV'] ||= 'test' +require_relative '../config/environment' +# Prevent database truncation if the environment is production +abort("The Rails environment is running in production mode!") if Rails.env.production? +# Uncomment the line below in case you have `--require rails_helper` in the `.rspec` file +# that will avoid rails generators crashing because migrations haven't been run yet +# return unless Rails.env.test? +require 'rspec/rails' +# Add additional requires below this line. Rails is not loaded until this point! + +# Requires supporting ruby files with custom matchers and macros, etc, in +# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are +# run as spec files by default. This means that files in spec/support that end +# in _spec.rb will both be required and run as specs, causing the specs to be +# run twice. It is recommended that you do not name files matching this glob to +# end with _spec.rb. You can configure this pattern with the --pattern +# option on the command line or in ~/.rspec, .rspec or `.rspec-local`. +# +# The following line is provided for convenience purposes. It has the downside +# of increasing the boot-up time by auto-requiring all files in the support +# directory. Alternatively, in the individual `*_spec.rb` files, manually +# require only the support files necessary. +# +# Rails.root.glob('spec/support/**/*.rb').sort_by(&:to_s).each { |f| require f } + +# Ensures that the test database schema matches the current schema file. +# If there are pending migrations it will invoke `db:test:prepare` to +# recreate the test database by loading the schema. +# If you are not using ActiveRecord, you can remove these lines. +begin + ActiveRecord::Migration.maintain_test_schema! +rescue ActiveRecord::PendingMigrationError => e + abort e.to_s.strip +end +RSpec.configure do |config| + # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures + config.fixture_paths = [ + Rails.root.join('spec/fixtures') + ] + + # If you're not using ActiveRecord, or you'd prefer not to run each of your + # examples within a transaction, remove the following line or assign false + # instead of true. + config.use_transactional_fixtures = true + + # You can uncomment this line to turn off ActiveRecord support entirely. + # config.use_active_record = false + + # RSpec Rails uses metadata to mix in different behaviours to your tests, + # for example enabling you to call `get` and `post` in request specs. e.g.: + # + # RSpec.describe UsersController, type: :request do + # # ... + # end + # + # The different available types are documented in the features, such as in + # https://rspec.info/features/8-0/rspec-rails + # + # You can also infer these behaviours automatically by location, e.g. + # /spec/models would pull in the same behaviour as `type: :model` but this + # behaviour is considered legacy and will be removed in a future version. + # + # To enable this behaviour uncomment the line below. + # config.infer_spec_type_from_file_location! + + # Filter lines from Rails gems in backtraces. + config.filter_rails_from_backtrace! + # arbitrary gems may also be filtered via: + # config.filter_gems_from_backtrace("gem name") +end diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb new file mode 100644 index 0000000000..327b58ea1f --- /dev/null +++ b/spec/spec_helper.rb @@ -0,0 +1,94 @@ +# This file was generated by the `rails generate rspec:install` command. Conventionally, all +# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. +# The generated `.rspec` file contains `--require spec_helper` which will cause +# this file to always be loaded, without a need to explicitly require it in any +# files. +# +# Given that it is always loaded, you are encouraged to keep this file as +# light-weight as possible. Requiring heavyweight dependencies from this file +# will add to the boot time of your test suite on EVERY test run, even for an +# individual file that may not need all of that loaded. Instead, consider making +# a separate helper file that requires the additional dependencies and performs +# the additional setup, and require it from the spec files that actually need +# it. +# +# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration +RSpec.configure do |config| + # rspec-expectations config goes here. You can use an alternate + # assertion/expectation library such as wrong or the stdlib/minitest + # assertions if you prefer. + config.expect_with :rspec do |expectations| + # This option will default to `true` in RSpec 4. It makes the `description` + # and `failure_message` of custom matchers include text for helper methods + # defined using `chain`, e.g.: + # be_bigger_than(2).and_smaller_than(4).description + # # => "be bigger than 2 and smaller than 4" + # ...rather than: + # # => "be bigger than 2" + expectations.include_chain_clauses_in_custom_matcher_descriptions = true + end + + # rspec-mocks config goes here. You can use an alternate test double + # library (such as bogus or mocha) by changing the `mock_with` option here. + config.mock_with :rspec do |mocks| + # Prevents you from mocking or stubbing a method that does not exist on + # a real object. This is generally recommended, and will default to + # `true` in RSpec 4. + mocks.verify_partial_doubles = true + end + + # This option will default to `:apply_to_host_groups` in RSpec 4 (and will + # have no way to turn it off -- the option exists only for backwards + # compatibility in RSpec 3). It causes shared context metadata to be + # inherited by the metadata hash of host groups and examples, rather than + # triggering implicit auto-inclusion in groups with matching metadata. + config.shared_context_metadata_behavior = :apply_to_host_groups + +# The settings below are suggested to provide a good initial experience +# with RSpec, but feel free to customize to your heart's content. +=begin + # This allows you to limit a spec run to individual examples or groups + # you care about by tagging them with `:focus` metadata. When nothing + # is tagged with `:focus`, all examples get run. RSpec also provides + # aliases for `it`, `describe`, and `context` that include `:focus` + # metadata: `fit`, `fdescribe` and `fcontext`, respectively. + config.filter_run_when_matching :focus + + # Allows RSpec to persist some state between runs in order to support + # the `--only-failures` and `--next-failure` CLI options. We recommend + # you configure your source control system to ignore this file. + config.example_status_persistence_file_path = "spec/examples.txt" + + # Limits the available syntax to the non-monkey patched syntax that is + # recommended. For more details, see: + # https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/ + config.disable_monkey_patching! + + # Many RSpec users commonly either run the entire suite or an individual + # file, and it's useful to allow more verbose output when running an + # individual spec file. + if config.files_to_run.one? + # Use the documentation formatter for detailed output, + # unless a formatter has already been configured + # (e.g. via a command-line flag). + config.default_formatter = "doc" + end + + # Print the 10 slowest examples and example groups at the + # end of the spec run, to help surface which specs are running + # particularly slow. + config.profile_examples = 10 + + # Run specs in random order to surface order dependencies. If you find an + # order dependency and want to debug it, you can fix the order by providing + # the seed, which is printed after each run. + # --seed 1234 + config.order = :random + + # Seed global randomization in this process using the `--seed` CLI option. + # Setting this allows you to use `--seed` to deterministically reproduce + # test failures related to randomization by passing the same `--seed` value + # as the one that triggered the failure. + Kernel.srand config.seed +=end +end diff --git a/storage/.keep b/storage/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/controllers/.keep b/test/controllers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/fixtures/files/.keep b/test/fixtures/files/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/helpers/.keep b/test/helpers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/integration/.keep b/test/integration/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/mailers/.keep b/test/mailers/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/models/.keep b/test/models/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000000..0c22470ec1 --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,15 @@ +ENV["RAILS_ENV"] ||= "test" +require_relative "../config/environment" +require "rails/test_help" + +module ActiveSupport + class TestCase + # Run tests in parallel with specified workers + parallelize(workers: :number_of_processors) + + # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. + fixtures :all + + # Add more helper methods to be used by all tests here... + end +end diff --git a/tmp/.keep b/tmp/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tmp/pids/.keep b/tmp/pids/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tmp/storage/.keep b/tmp/storage/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/.keep b/vendor/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/vendor/javascript/.keep b/vendor/javascript/.keep new file mode 100644 index 0000000000..e69de29bb2