upcase in the model instead of in the view

This commit is contained in:
Alexis Reigel 2017-07-25 16:23:52 +02:00
parent f86580c075
commit 98531fc248
4 changed files with 14 additions and 2 deletions

View file

@ -37,6 +37,14 @@ class GpgKey < ActiveRecord::Base
after_commit :update_invalid_gpg_signatures, on: :create
after_commit :notify_user, on: :create
def primary_keyid
super&.upcase
end
def fingerprint
super&.upcase
end
def key=(value)
value.strip! unless value.blank?
write_attribute(:key, value)

View file

@ -11,6 +11,10 @@ class GpgSignature < ActiveRecord::Base
validates :project, presence: true
validates :gpg_key_primary_keyid, presence: true
def gpg_key_primary_keyid
super&.upcase
end
def commit
project.commit(commit_sha)
end

View file

@ -6,7 +6,7 @@
= render partial: 'email_with_badge', locals: { email: email, verified: verified }
.description
%code= key.fingerprint.upcase
%code= key.fingerprint
.pull-right
%span.key-created-at
created #{time_ago_with_tooltip(key.created_at)}

View file

@ -9,7 +9,7 @@
= content
GPG Key ID:
%span.monospace= signature.gpg_key_primary_keyid.upcase
%span.monospace= signature.gpg_key_primary_keyid
= link_to('Learn more about signing commits', help_page_path('workflow/gpg_signed_commits/index.md'), class: 'gpg-popover-help-link')