summaryrefslogtreecommitdiff
path: root/app/controllers
diff options
context:
space:
mode:
authorelijah <elijah@riseup.net>2016-01-14 16:14:39 -0800
committerelijah <elijah@riseup.net>2016-01-14 16:14:39 -0800
commit6dba1392a29a003c3334259a222061f29ff04b13 (patch)
treee3161cf87ecec5ebc095adf55f66db1e21c17cbb /app/controllers
parentdd2518c40ab06f51d0f7380f1521087d3a4fbd5f (diff)
added UI for invite codes
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/invite_codes_controller.rb35
1 files changed, 35 insertions, 0 deletions
diff --git a/app/controllers/invite_codes_controller.rb b/app/controllers/invite_codes_controller.rb
new file mode 100644
index 0000000..6a7fef3
--- /dev/null
+++ b/app/controllers/invite_codes_controller.rb
@@ -0,0 +1,35 @@
+class InviteCodesController < ApplicationController
+
+ respond_to :html
+ before_filter :require_login
+ before_filter :require_admin
+ before_filter :fetch_invite, only: :destroy
+
+ def index
+ @invite = InviteCode.new # for the creation form.
+ @invites = InviteCode.all.page(params[:page]).per(APP_CONFIG[:pagination_size])
+ respond_with @invites
+ end
+
+ def create
+ @invite = InviteCode.new(params[:invite_code])
+ @invite.save # throws exception on error (!)
+ flash[:success] = t('created') + " #{@invite.invite_code}"
+ rescue
+ flash[:error] = "could not save invite code" # who knows why, invite.errors is empty
+ ensure
+ redirect_to invite_codes_path
+ end
+
+ def destroy
+ @invite.destroy
+ redirect_to invite_codes_path
+ end
+
+ protected
+
+ def fetch_invite
+ @invite = InviteCode.find(params[:id])
+ end
+
+end