This repository has been archived by the owner on Apr 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
183 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
= flash_tag(:error) | ||
= form_for badge, url(:badges, :create), id: 'new_badge' do |f| | ||
= f.error_messages | ||
%div.form-group | ||
= f.label :label, caption: "Badge label" | ||
= f.text_field :label, placeholder: 'ember-versions', class: 'form-control' | ||
%div.form-group | ||
= f.label :title, caption: "Title of your page (for later identification)" | ||
= f.text_field :title, placeholder: 'Amazing article about Ember.js', class: 'form-control' | ||
%div.form-group | ||
= f.label :url, caption: "URL this badge will appear on" | ||
= f.text_field :url, placeholder: 'http://myblog.com/ember-js-rocks', class: 'form-control' | ||
%div.form-group | ||
= f.label :version_start | ||
= f.text_field :version_start, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_end | ||
= f.text_field :version_end, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_range | ||
= f.text_field :version_range, class: 'form-control' | ||
= f.error_messages | ||
%div.form-group | ||
= f.label :label, caption: "Badge label" | ||
= f.text_field :label, placeholder: 'ember-versions', class: 'form-control' | ||
%div.form-group | ||
= f.label :title, caption: "Title of your page (for later identification)" | ||
= f.text_field :title, placeholder: 'Amazing article about Ember.js', class: 'form-control' | ||
%div.form-group | ||
= f.label :url, caption: "URL this badge will appear on" | ||
= f.url_field :url, placeholder: 'http://myblog.com/ember-js-rocks', class: 'form-control' | ||
%div.form-group | ||
= f.label :version_start | ||
= f.text_field :version_start, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_end | ||
= f.text_field :version_end, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_range | ||
= f.text_field :version_range, class: 'form-control' | ||
|
||
%div.form-group | ||
= f.submit "Submit", class: 'btn btn-default' | ||
%div.form-group | ||
= f.submit "Submit", class: 'btn btn-default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
%h2 Edit badge | ||
= partial 'badges/form', locals: {badge: @badge} | ||
= flash_tag(:error) | ||
= form_for @badge, url(:badges, :update, id: @badge.id), id: 'update_badge', method: :put do |f| | ||
= partial 'badges/form', locals: {f: f} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
%h2 New Badge | ||
= partial 'badges/form', locals: {badge: @badge} | ||
= flash_tag(:error) | ||
= form_for @badge, url(:badges, :create), id: 'new_badge' do |f| | ||
= partial 'badges/form', locals: {f: f} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,16 @@ | ||
= flash_tag(:error) | ||
= form_for badge, url(:badge_infos, :create), id: 'new_badge' do |f| | ||
= f.error_messages | ||
%div.form-group | ||
= f.label :label, caption: "Badge label" | ||
= f.text_field :label, placeholder: 'ember-versions', class: 'form-control' | ||
%div.form-group | ||
= f.label :title, caption: "Title of your page (for later identification)" | ||
= f.text_field :title, placeholder: 'Amazing article about Ember.js', class: 'form-control' | ||
%div.form-group | ||
= f.label :url, caption: "URL this badge will appear on" | ||
= f.text_field :url, placeholder: 'http://myblog.com/ember-js-rocks', class: 'form-control' | ||
= f.fields_for :badge_infos do |bi| | ||
%div.form-group | ||
= bi.label :version_start | ||
= bi.text_field :version_start, class: 'form-control' | ||
%div.form-group | ||
= bi.label :version_end | ||
= bi.text_field :version_end, class: 'form-control' | ||
%div.form-group | ||
= bi.label :version_range | ||
= bi.text_field :version_range, class: 'form-control' | ||
= f.error_messages | ||
%div.form-group | ||
= f.label :version_start | ||
= f.text_field :version_start, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_end | ||
= f.text_field :version_end, class: 'form-control' | ||
%div.form-group | ||
= f.label :version_range | ||
= f.text_field :version_range, class: 'form-control' | ||
%div.form-group | ||
= f.label :comment | ||
= f.text_area :comment, class: 'form-control' | ||
|
||
%div.form-group | ||
= f.submit "Submit", :class => 'btn btn-default' | ||
%div.form-group | ||
= f.submit "Submit", class: 'btn btn-default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
%h2 Propose Change | ||
= partial 'badge_infos/form', locals: {badge: @badge} | ||
= flash_tag(:error) | ||
= form_for @change, url(:changes, :create, id: @badge.id), id: 'new_change' do |f| | ||
= partial 'changes/form', locals: {f: f} | ||
|
||
%a{href: url(:badges, :show, id: @badge.id)} Back to badge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,36 @@ | ||
class BadgeChange < ActiveRecord::Base | ||
has_many :votes | ||
belongs_to :badge | ||
belongs_to :user | ||
|
||
validates_presence_of :version_start, if: -> { self.version_range.blank? } | ||
validates_presence_of :version_range, if: -> { self.version_start.blank? } | ||
validates :version_start, presence: true, if: -> { self.version_range.blank? } | ||
validates :version_range, presence: true, if: -> { self.version_start.blank? } | ||
validates :badge, presence: true | ||
validates :user, presence: true | ||
|
||
has_many :votes | ||
belongs_to :badge | ||
belongs_to :user | ||
VALID_STATUSES = %w(proposed rejected accepted) | ||
validates :status, inclusion: { in: VALID_STATUSES, | ||
message: "%{value} is not a valid status" } | ||
|
||
VALID_STATUSES.each do |status_name| | ||
scope status_name, -> { where(status: status_name) } | ||
|
||
define_method("#{status_name}?") do | ||
status == status_name | ||
end | ||
end | ||
|
||
# Sets status to accepted. | ||
# Rejects all other changes. | ||
# Copies attributes over to badge | ||
def accept! | ||
badge.apply! self | ||
self.status = :accepted | ||
self.save | ||
end | ||
|
||
def reject! | ||
self.status = :rejected | ||
self.save! | ||
end | ||
end |