Browse Source

Ultimos cambios funcionando

main
rodley82 3 years ago
parent
commit
e1c00e319e
  1. 3
      Dockerfile
  2. 5
      app/admin/users_admin.rb
  3. 1
      app/models/work_experience.rb
  4. 6
      app/views/templates/awesome/resume.html.erb
  5. 1
      db/migrate/20220903004934_add_extra_columns.rb
  6. 5
      db/migrate/20220903211620_add_items_csv_to_education.rb
  7. 4
      db/schema.rb

3
Dockerfile

@ -26,8 +26,7 @@ COPY --chown=${REGULAR_USER}:${REGULAR_USER} Gemfile Gemfile.lock ./
# RUN bundle config set --local without 'development test'
RUN bundle install
COPY --chown=${REGULAR_USER}:${REGULAR_USER} . .
# COPY --chown=${REGULAR_USER}:${REGULAR_USER} . .
EXPOSE 3000

5
app/admin/users_admin.rb

@ -11,7 +11,7 @@ Trestle.resource(:users) do
actions do |toolbar, instance, admin|
toolbar.edit if admin && admin.actions.include?(:edit)
toolbar.delete if admin && admin.actions.include?(:destroy)
toolbar.link 'Template 1', instance, action: :generate, method: :post, style: :primary, icon: "fa fa-file-pdf", target: "_blank"
toolbar.link 'Template 1', instance, action: :generate, method: :get, style: :primary, icon: "fa fa-file-pdf"
end
end
@ -19,6 +19,7 @@ Trestle.resource(:users) do
def generate
user = admin.find_instance(params)
ac = ActionController::Base.new()
# debugger
tex_content = ac.render_to_string(layout: false, template: 'templates/awesome/resume', locals: { "@user": user } )
destination_dir = "#{Rails.root}/app/views/templates/awesome"
`cd #{destination_dir} && make clean`
@ -31,6 +32,6 @@ Trestle.resource(:users) do
end
routes do
post :generate, on: :member
get :generate, on: :member
end
end

1
app/models/work_experience.rb

@ -1,3 +1,4 @@
class WorkExperience < ApplicationRecord
belongs_to :user
default_scope -> { order(reference_date: :desc) }
end

6
app/views/templates/awesome/resume.html.erb

@ -52,7 +52,7 @@
% Available options: circle|rectangle,edge/noedge,left/right
% \photo[rectangle,edge,right]{./examples/profile}
\name{<%= @user.name %>}{}
\position{Software Engineer{\enskip\cdotp\enskip}Security Expert}
\position{<%= @user.title %>}
\address{<%= @user.address %>}
\mobile{<%= @user.phone %>}
@ -143,7 +143,7 @@
{<%= w.period %>} % Date(s)
{
\begin{cvitems} % Description(s) of tasks/responsibilities
<% w.items_csv.split(",").each do |i| %>
<% w.items_csv&.split(",")&.each do |i| %>
\item {<%= i %>}
<% end %>
\end{cvitems}
@ -166,8 +166,8 @@
%---------------------------------------------------------
<% @user.education_entries.each do |e| %>
\cventry
{<%= e.title %>} % Degree
{<%= e.institution %>} % Institution
{<%= e.title %>} % Degree
{<%= e.location %>} % Location
{<%= e.period %>} % Date(s)
{

1
db/migrate/20220903004934_add_extra_columns.rb

@ -2,5 +2,6 @@ class AddExtraColumns < ActiveRecord::Migration[7.0]
def change
add_column :work_experiences, :items_csv, :text
add_column :education_entries, :reference_date, :date
add_column :users, :title, :string
end
end

5
db/migrate/20220903211620_add_items_csv_to_education.rb

@ -0,0 +1,5 @@
class AddItemsCsvToEducation < ActiveRecord::Migration[7.0]
def change
add_column :education_entries, :items_csv, :text
end
end

4
db/schema.rb

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema[7.0].define(version: 2022_09_03_004934) do
ActiveRecord::Schema[7.0].define(version: 2022_09_03_211620) do
create_table "education_entries", force: :cascade do |t|
t.string "title"
t.string "institution"
@ -20,6 +20,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_03_004934) do
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "reference_date"
t.text "items_csv"
t.index ["user_id"], name: "index_education_entries_on_user_id"
end
@ -44,6 +45,7 @@ ActiveRecord::Schema[7.0].define(version: 2022_09_03_004934) do
t.string "other_page_url"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "title"
end
create_table "work_experiences", force: :cascade do |t|

Loading…
Cancel
Save