-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replaced organization github name and project repo fields with Project github url #286
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,23 @@ | ||
class Organization < ActiveRecord::Base | ||
before_save :delete_logo | ||
before_create :set_github_org | ||
|
||
has_many :jobs | ||
has_many :projects | ||
has_many :organization_metrics | ||
has_many :sponsorships | ||
|
||
attr_accessible :name, :url, :github_org, :description, :is_tax_exempt, :contact_name, :contact_role, :contact_email, :annual_budget_usd, :total_staff_size, :tech_staff_size, :notes, :image_url, :twitter, :logo, :logo_delete | ||
attr_accessible :name, :url, :github_org, :description, | ||
:is_tax_exempt, :contact_name, :contact_role, | ||
:contact_email, :annual_budget_usd, :total_staff_size, | ||
:tech_staff_size, :notes, :image_url, :twitter, :logo, | ||
:logo_delete | ||
attr_accessible :organization_metrics_attributes, :projects_attributes | ||
|
||
attr_writer :logo_delete | ||
attr_accessor :is_public_submission | ||
|
||
validates_presence_of :name | ||
validates_presence_of :github_org, if: :is_public_submission | ||
validates :name, presence: true | ||
|
||
# Paperclip | ||
has_attached_file :logo, styles: { thumb: '100x100>', medium: '250x250>' }, | ||
|
@@ -48,4 +52,12 @@ def logo_delete | |
def delete_logo | ||
logo.clear if logo_delete == '1' | ||
end | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Extra empty line detected at class body end. |
||
def set_github_org | ||
if projects.first | ||
self.github_org = Project.parse_git_url(projects.first.submitted_github_url) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [82/80] |
||
.split('/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the previous line, together with the method call receiver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the previous line, together with the method call receiver. |
||
.first | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the previous line, together with the method call receiver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the previous line, together with the method call receiver. |
||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,21 @@ | ||
class Project < ActiveRecord::Base | ||
before_create :set_github_repo | ||
belongs_to :organization | ||
acts_as_ordered_taggable | ||
acts_as_ordered_taggable_on :technologies, :causes | ||
|
||
attr_accessible :cause_list, :description, :github_repo, :help_url, | ||
:install_url, :is_active, :is_approved, :name, :notes, | ||
:organization_id, :technology_list, :url, :twitter | ||
validates_presence_of :name, :github_repo | ||
:organization_id, :technology_list, :url, :twitter, | ||
:submitted_github_url | ||
|
||
attr_accessor :submitted_github_url | ||
validates :name, presence: true | ||
validates :github_repo, presence: true, on: :update | ||
validates :submitted_github_url, presence: true, | ||
format: { with: /\Ahttps?:\/\/github.com\/[\w-]+\/[\w\.-]+(\/)?\Z/i, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [81/80] |
||
message: 'Please enter a valid GitHub URL.' }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
on: :create | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Align the elements of a hash literal if they span more than one line. |
||
|
||
has_many :favorite_projects | ||
has_many :users, through: :favorite_projects | ||
|
@@ -60,4 +69,15 @@ def related_projects | |
def tasks_url | ||
"#{github_url}/issues" | ||
end | ||
|
||
def self.parse_git_url(url) | ||
url.gsub(/^(((https|http|git)?:\/\/(www\.)?)|git@)github.com(:|\/)/i, '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer double-quoted strings unless you need single quotes to avoid extra backslashes for escaping. |
||
.gsub(/(\.git|\/)$/i, '') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the previous line, together with the method call receiver. |
||
end | ||
|
||
private | ||
|
||
def set_github_repo | ||
self.github_repo = Project.parse_git_url(submitted_github_url).split('/').last | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line is too long. [82/80] |
||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trailing whitespace detected.