Skip to content

Commit ef630be

Browse files
committed
set_team_admins [WIP]
1 parent 09ec2e5 commit ef630be

File tree

7 files changed

+15
-29
lines changed

7 files changed

+15
-29
lines changed

app/controllers/teams_controller.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,10 @@ def followed
2222
def show
2323
#FIXME
2424
show_params = params.permit(:job_id, :refresh, :callback, :id, :slug)
25+
@team = team_from_params(slug: show_params[:slug], id: show_params[:id])
2526

2627
respond_to do |format|
2728
format.html do
28-
@team = team_from_params(slug: show_params[:slug], id: show_params[:id])
29-
3029
return render_404 if @team.nil?
3130

3231
@team_protips = @team.trending_protips(4)
@@ -45,7 +44,6 @@ def show
4544
options[:force] = true if !show_params[:refresh].blank?
4645
response = Rails.cache.fetch(['v1', 'team', show_params[:id], :json], options) do
4746
begin
48-
@team = team_from_params(slug: show_params[:slug], id: show_params[:id])
4947
@team.public_json
5048
rescue ActiveRecord::RecordNotFound
5149
return head(:not_found)
@@ -95,9 +93,8 @@ def create
9593
#end
9694

9795
def edit
98-
edit_params = params.permit(:slug, :id)
99-
100-
@team = team_from_params(slug: edit_params[:slug], id: edit_params[:id])
96+
#TODO, change slug to citext
97+
@team = Team.find_by_slug(params[:slug])
10198
return head(:forbidden) unless current_user.belongs_to_team?(@team) || current_user.admin?
10299
@edit_mode = true
103100
show

app/models/team.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,7 @@ def predominant
613613
def admin?(user)
614614
return false if user.nil?
615615
return true if user.admin?
616-
if admins.empty?
617-
members.include?(user)
618-
else
619-
admins.include?(user.id)
620-
end
616+
admins.pluck(:user_id).include?(user.id)
621617
end
622618

623619
def timeline_key

app/models/user.rb

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,12 +375,6 @@ def total_achievements
375375
badges_count
376376
end
377377

378-
def has_beta_access?
379-
admin? || beta_access
380-
end
381-
382-
383-
384378
def to_csv
385379
[
386380
display_name,

app/views/teams/show.html.haml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,4 @@
148148
.add-members-header
149149
%h3 Invite team members
150150
%h4 Email this link to your colleagues so they can join this team
151-
=mail_to('', invite_to_team_url, :body => invite_to_team_url, :subject => "You've been invited to team #{@team.name}", :class => 'join-link')
152-
-elsif viewing_my_team_while_unauthenticated?
153-
#add-to-team.hide
154-
.add-members-header
155-
%h3 Add team members
156-
%h4 Sign in to get an invite link to send to your colleagues
157-
=link_to("Sign In", signin_path, :class => 'join-link record-exit', 'data-target-type' => 'signin')
158-
159-
-#-if signed_in? && current_user.try(:team) == @team
160-
-# =mail_to('teams@coderwall.com', "Is #{current_user.team.name} awesome and hiring? Upgrade to the new enhanced team profile now.", :subject => "Create an enhanced team profile on Coderwall", :body => "Company Name: #{current_user.try(:team).try(:name)}", :class => 'feature-signup track', 'data-action' => 'upgrade-from-my-team-page')
151+
=mail_to('', invite_to_team_url, :body => invite_to_team_url, :subject => "You've been invited to team #{@team.name}", :class => 'join-link')

config/environments/development.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
# Log the query plan for queries taking more than this (works
2828
# with SQLite, MySQL, and PostgreSQL)
29-
config.active_record.auto_explain_threshold_in_seconds = 0.5
29+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
3030

3131
# Move cache dir's out of vagrant NFS directory
3232
config.cache_store = [:file_store,"/tmp/codewall-cache/"]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
class SetTeamAdmins < ActiveRecord::Migration
2+
def up
3+
# doing that for teams with one member for now
4+
Team.where(team_size: 1).find_each do |team|
5+
team.members.first.update_attribute('role', 'admin')
6+
end
7+
end
8+
end

db/schema.rb

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

14-
ActiveRecord::Schema.define(:version => 20150109004213) do
14+
ActiveRecord::Schema.define(:version => 20150109101515) do
1515

1616
add_extension "citext"
1717
add_extension "hstore"

0 commit comments

Comments
 (0)