Skip to content

Commit

Permalink
Merge branch 'undisable'
Browse files Browse the repository at this point in the history
  • Loading branch information
sodabrew committed Jul 16, 2014
2 parents b2030a9 + b466ad6 commit b9e97da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion code/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
module RQ
class Main < Sinatra::Base

disable :protection
enable :sessions
set :session_secret, 'super secret' # we are forking, so we must set
set :erb, :trim => '-'
Expand All @@ -25,6 +24,10 @@ def url
"http://#{request.host}:#{request.port}/"
end

def new_queue_allowed
%w{test development}.include? ENV["RQ_ENV"]
end

def get_queueclient(name)
# SPECIAL CASE - we allow relay and cleaner
# No RQ should be connecting to another box's relay
Expand Down Expand Up @@ -70,10 +73,13 @@ def flash(type, msg)
end

get '/new_queue' do
throw :halt, [403, "Queue creation not allowed at this time."] unless new_queue_allowed

erb :new_queue
end

post '/new_queue' do
throw :halt, [403, "Queue creation not allowed at this time."] unless new_queue_allowed
# TODO: validation

# This creates and starts a queue
Expand All @@ -83,6 +89,8 @@ def flash(type, msg)
end

post '/new_queue_link' do
throw :halt, [403, "Queue creation not allowed at this time."] unless new_queue_allowed

# This creates and starts a queue via a config file in json
js_data = {}
begin
Expand Down
2 changes: 2 additions & 0 deletions code/views/main.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<div id="header">
<% if new_queue_allowed -%>
<p id="new-queue"><a href="/new_queue">New Queue</a></p>
<% end -%>
<h1><a href="<%= url %>">RQ</a></h1>
</div>

Expand Down

0 comments on commit b9e97da

Please sign in to comment.