FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

opt-in for projects · bashgnu/tip4commit@68f3e22 · GitHub

Repository navigation

Commit 68f3e22

Browse files
committed
opt-in for projects
1 parent 93e8ecd commit 68f3e22

10 files changed

Lines changed: 42 additions & 8 deletions

File tree

‎Gemfile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ gem 'cancancan'
2929
gem 'dusen'
3030
gem 'render_csv'
3131
gem 'demoji'
32+
gem 'acts_as_paranoid', github: 'ActsAsParanoid/acts_as_paranoid'
3233

3334
gem "http_accept_language"
3435
gem 'rails-i18n'

‎Gemfile.lock‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
GIT
2+
remote: git://github.com/ActsAsParanoid/acts_as_paranoid.git
3+
revision: ddcd1915179c73f74985af6bc8935321ca2fe08d
4+
specs:
5+
acts_as_paranoid (0.5.0.beta1)
6+
activerecord (~> 4.0)
7+
activesupport (~> 4.0)
8+
19
GIT
210
remote: git://github.com/alexandrz/omniauth-github.git
311
revision: 37a030aa37659831ef80af21b5c7270fe1384b3c
@@ -316,6 +324,7 @@ PLATFORMS
316324
ruby
317325

318326
DEPENDENCIES
327+
acts_as_paranoid!
319328
airbrake (~> 3.1.15)
320329
bootstrap_form!
321330
cancancan

‎app/controllers/projects_controller.rb‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def search
1414
return render :blacklisted
1515
end
1616

17-
if project = Project.find_or_create_by_url(params[:query])
17+
if project = Project.find_by_url(params[:query])
1818
redirect_to pretty_project_path(project)
1919
else
2020
@projects = Project.search(params[:query].to_s).order(projects_order).page(params[:page]).per(30)

‎app/models/project.rb‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
class Project < ActiveRecord::Base
2+
acts_as_paranoid
3+
24
has_many :deposits # todo: only confirmed deposits
35
has_many :tips, inverse_of: :project
46
accepts_nested_attributes_for :tips
@@ -217,6 +219,15 @@ def self.find_or_create_by_url project_url
217219
Github.new.find_or_create_project project_name
218220
end
219221

222+
def self.find_by_url project_url
223+
project_name = project_url.
224+
gsub(/https?\:\/\/github.com\//, '').
225+
gsub(/\#.+$/, '').
226+
gsub(' ', '')
227+
228+
Github.new.find_project project_name
229+
end
230+
220231
# Removes inactive addresses from the wallet
221232
# Description: https://blockchain.info/api/blockchain_wallet_api
222233
def self.consolidate_addresses

‎app/services/github.rb‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def repository_info project
4545
end
4646

4747
def find_or_create_project project_name
48-
if project = Project.find_by(host: "github", full_name: project_name)
48+
if project = find_project(project_name)
4949
project
5050
elsif project_name =~ /\w+\/\w+/
5151
begin
@@ -61,6 +61,10 @@ def find_or_create_project project_name
6161
end
6262
end
6363

64+
def find_project project_name
65+
return Project.find_by(host: "github", full_name: project_name)
66+
end
67+
6468
def collaborators_info project
6569
(client.get("/repos/#{project.full_name}/collaborators") rescue []) +
6670
(client.get("/orgs/#{project.full_name.split('/').first}/members") rescue [])

‎app/views/projects/index.html.haml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,6 @@
3939
%td= link_to t('.support'), pretty_project_path(project), class: 'btn btn-xs btn-success'
4040
= paginate @projects
4141
- else
42-
.alert.alert-warning{role: 'alert'}= I18n.t('errors.project_not_found')
42+
.alert.alert-warning{role: 'alert'}
43+
= I18n.t('errors.project_not_found')
44+
= I18n.t('errors.opt_in_notice')

‎config/locales/en.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ en:
1818
sign_out: Sign out
1919
errors:
2020
project_not_found: Project not found.
21+
opt_in_notice: Because of multiple complains to GitHub we had to make Tip4Commit opt-in for project maintainers and removed all projects that don't have deposits. If you want to add your project please create an issue at GitHub.
2122
access_denied: Access denied
2223
can_assign_more_tips: "You can't assign more than 100% of available funds."
2324
wrong_bitcoin_address: Error updating bitcoin address
@@ -69,8 +70,8 @@ en:
6970
projects:
7071
index:
7172
find_project:
72-
placeholder: Enter GitHub project URL to add a project or any keyword to find it...
73-
button: Find or add project
73+
placeholder: Enter GitHub project URL or any keyword to find it...
74+
button: Find project
7475
repository: Repository
7576
description: Description
7677
watchers: Watchers

‎config/locales/ru.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ ru:
6969
projects:
7070
index:
7171
find_project:
72-
placeholder: Введите GitHub адрес вашего проекта чтобы добавить его или ключевое слово для поиска...
73-
button: Найти или добавить проект
72+
placeholder: Введите GitHub адрес проекта или ключевое слово для поиска...
73+
button: Найти проект
7474
repository: Репозиторий
7575
description: Описание
7676
watchers: Наблюдателей
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddDeletedAtToProjects < ActiveRecord::Migration
2+
def change
3+
add_column :projects, :deleted_at, :timestamp
4+
end
5+
end

‎db/schema.rb‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# It's strongly recommended that you check this file into your version control system.
1313

14-
ActiveRecord::Schema.define(version: 20141029083726) do
14+
ActiveRecord::Schema.define(version: 20141112064004) do
1515

1616
create_table "collaborators", force: true do |t|
1717
t.integer "project_id"
@@ -54,6 +54,7 @@
5454
t.string "branch"
5555
t.boolean "disable_notifications"
5656
t.string "avatar_url"
57+
t.datetime "deleted_at"
5758
end
5859

5960
add_index "projects", ["full_name"], name: "index_projects_on_full_name", unique: true

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL