Skip to content

Commit

Permalink
removing watermark when signature is qr code and changing ability to …
Browse files Browse the repository at this point in the history
…prevent academic_transcript generation if not dismissed with degree
  • Loading branch information
anderson-mj committed Jan 14, 2025
1 parent 3961bad commit 7b571bc
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 12 deletions.
5 changes: 5 additions & 0 deletions app/controllers/enrollments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ def override_signature_grades_report_pdf

def academic_transcript_pdf(signature_type = nil)
enrollment = Enrollment.find(params[:id])

if cannot? :academic_transcript_pdf, enrollment
raise CanCan::AccessDenied.new
end

respond_to do |format|
format.pdf do
title = I18n.t("pdf_content.enrollment.academic_transcript.title")
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/pdf_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def new_document(name, title, options = {}, &block)
datetime_footer(pdf)
end
end
if options[:watermark]
if options[:watermark] && pdf_config.signature_type != "qr_code"
pdf.create_stamp("watermark") do
pdf.rotate(60, origin: [0, 0]) do
pdf.fill_color "993333"
Expand Down
6 changes: 6 additions & 0 deletions app/models/ability.rb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def initialize_students(user, roles)
can :manage, Ability::STUDENT_MODELS
can :update_all_fields, Student
can :read_all_fields, Student
can :override_report_signature_type, Enrollment
can :generate_report_without_watermark, Enrollment
can :invite, User
end
Expand All @@ -137,6 +138,11 @@ def initialize_students(user, roles)
if roles[Role::ROLE_SUPORTE]
can [:read, :update, :update_only_photo], (Student)
end

# Keep this at the end or :read STUDENT_MODELS will override it
cannot :academic_transcript_pdf, Enrollment do |enrollment|
enrollment.dismissal&.dismissal_reason&.thesis_judgement != DismissalReason::APPROVED
end unless roles[:manager]
end

def initialize_professors(user, roles)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
<div style="display: flex; gap: 20px;">
<%= link_to 'Sem Assinatura', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :no_signature), target: "_blank" %>
<%= link_to 'Assinatura Manual', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :manual), target: "_blank" %>
<%= link_to 'Assinatura por QR Code', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :qr_code), target: "_blank" %>
<% if can?(:academic_transcript_pdf, @record) %>
<% if can?(:override_report_signature_type, @record) %>
<%= link_to_if can?(:academic_transcript_pdf, @record), 'Sem Assinatura', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :no_signature), target: "_blank" %>
<%= link_to 'Assinatura Manual', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :manual), target: "_blank" %>
<%= link_to 'Assinatura por QR Code', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :qr_code), target: "_blank" %>
<% else %>
<%= link_to 'Gerar', academic_transcript_pdf_enrollment_path(id: @record.id, format: :pdf), target: "_blank" %>
<% end %>
<% else %>
-
<% end %>
</div>
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<div style="display: flex; flex-direction: column; gap: 10px;">
<div style="display: flex; justify-content: space-around; gap: 20px;">
<%= link_to 'Sem Assinatura', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :no_signature, transcript: true), target: "_blank" %>
<%= link_to 'Assinatura Manual', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :manual, transcript: true), target: "_blank" %>
<%= link_to 'Assinatura por QR Code', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :qr_code, transcript: true), target: "_blank" %>
</div>
<div style="display: flex; gap: 20px;">
<% if can?(:override_report_signature_type, @record) %>
<%= link_to 'Sem Assinatura', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :no_signature, transcript: true), target: "_blank" %>
<%= link_to 'Assinatura Manual', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :manual, transcript: true), target: "_blank" %>
<%= link_to 'Assinatura por QR Code', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :qr_code, transcript: true), target: "_blank" %>
<% else %>
<%= link_to 'Gerar', grades_report_pdf_enrollment_path(id: @record.id, format: :pdf), target: "_blank" %>
<% end %>
</div>
2 changes: 1 addition & 1 deletion app/views/enrollments/academic_transcript_pdf.pdf.prawn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ new_document(
:generate_report_without_watermark, @enrollment
),
pdf_type: :transcript,
signature_override: @signature_override
signature_override: can?(:override_report_type, @enrollment) ? @signature_type : nil
) do |pdf|
enrollment_student_header(pdf, enrollment: @enrollment)

Expand Down
2 changes: 1 addition & 1 deletion app/views/enrollments/grades_report_pdf.pdf.prawn
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ new_document(
)
),
pdf_type: :grades_report,
signature_override: @signature_override
signature_override: can?(:generate_report_without_qrcode, @enrollment) ? @signature_override : nil
) do |pdf|
enrollment_student_header(pdf, enrollment: @enrollment)

Expand Down

0 comments on commit 7b571bc

Please sign in to comment.