{"action":"created","comment":{"url":"https://api.github.com/repos/fsek/web/pulls/comments/27022422","id":27022422,"diff_hunk":"@@ -0,0 +1,136 @@\n+# encoding:UTF-8\n+class EventRegistrationsController < ApplicationController\n+  \n+    before_action :login_required\n+\t\tbefore_action :is_registrable, only: [:index, :new, :create]\n+\t\tbefore_action :authenticate_admin, only: :event_index\n+    before_action :authenticate, only: [:edit,:update,:show,:destroy]\n+\t\tbefore_action :authenticate_user, only: :profile_index\n+    before_action :set_event_registration, only: [:show,:edit,:update,:destroy]\n+    before_action :set_event, only: [:destroy, :new,:create, :edit, :index, :update]\n+\n+\tdef index\n+\t\t@text = \"\"\n+\t\t@reserved = EventRegistration.where(event_id: params[:event_id]).count\n+\t\t@new = nil\n+\t\t@event_registration = EventRegistration.where(profile_id: current_user.profile.id, event_id: params[:event_id]).first\n+\t\tif @event_registration.nil?\n+\t\t\t@new = 1\n+\t\t\t@event_registration = EventRegistration.new\n+\t\tend\n+\t\tif !@new && @event_registration.reserve_spot\n+\t\t\t@text =\t\"- Du ligger som reserv för eventet.\"\n+\t\telsif !@new && !@event_registration.reserve_spot \n+\t\t\t@text =\t\"- Du är anmäld till eventet.\"\n+\t\tend\n+    respond_to do |format|\n+      format.html { render }\n+      format.json { render :json => @event_registrations }\n+    end\n+\tend\n+        \n+  def event_index\n+\t\t@event = Event.find_by_id(params[:id])\n+    @event_registrations = EventRegistration.where(event_id: params[:id])\n+    respond_to do |format|\n+      format.html { render :event_index }\n+      format.json { render :json => @event_registrations }\n+    end\n+  end\n+\n+\tdef profile_index\n+\t\t@profile = Profile.find_by_id(params[:id])\n+    @event = @profile.events.where('starts_at > ?', Time.zone.now.beginning_of_day).order(starts_at: :desc)\n+    respond_to do |format|\n+      format.html { render :profile_index }\n+      format.json { render :json => @event_registrations }\n+    end\n+\tend\n+\n+  def show\n+    respond_to do |format|\n+      format.html # show.html.erb\n+      format.json { render :json => @event_registration }\n+    end\n+  end\n+\n+  def edit\n+  end\n+\n+  def create\n+    @event_registration = EventRegistration.new(event_registration_params)\n+\t\t@event_registration.profile_id = current_user.profile.id\n+\t\t@event_registration.event_id = @event.id\n+\t\t@event_registration.reserve_spot = @event.number_of_slots.present? && @event.event_registrations.count >= @event.number_of_slots ","path":"app/controllers/event_registrations_controller.rb","position":64,"original_position":64,"commit_id":"afc2acb45ef26be9fc63d9e9059a8316e53f1576","original_commit_id":"afc2acb45ef26be9fc63d9e9059a8316e53f1576","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Line is too long. [131/80]<br>Inconsistent indentation detected.<br>Tab detected.<br>Trailing whitespace detected.","created_at":"2015-03-24T12:28:41Z","updated_at":"2015-03-24T12:28:41Z","html_url":"https://github.com/fsek/web/pull/112#discussion_r27022422","pull_request_url":"https://api.github.com/repos/fsek/web/pulls/112","_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/comments/27022422"},"html":{"href":"https://github.com/fsek/web/pull/112#discussion_r27022422"},"pull_request":{"href":"https://api.github.com/repos/fsek/web/pulls/112"}}},"pull_request":{"url":"https://api.github.com/repos/fsek/web/pulls/112","id":31821334,"html_url":"https://github.com/fsek/web/pull/112","diff_url":"https://github.com/fsek/web/pull/112.diff","patch_url":"https://github.com/fsek/web/pull/112.patch","issue_url":"https://api.github.com/repos/fsek/web/issues/112","number":112,"state":"open","locked":false,"title":"Event anmalan","user":{"login":"albheim","id":3112674,"avatar_url":"https://avatars.githubusercontent.com/u/3112674?v=3","gravatar_id":"","url":"https://api.github.com/users/albheim","html_url":"https://github.com/albheim","followers_url":"https://api.github.com/users/albheim/followers","following_url":"https://api.github.com/users/albheim/following{/other_user}","gists_url":"https://api.github.com/users/albheim/gists{/gist_id}","starred_url":"https://api.github.com/users/albheim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/albheim/subscriptions","organizations_url":"https://api.github.com/users/albheim/orgs","repos_url":"https://api.github.com/users/albheim/repos","events_url":"https://api.github.com/users/albheim/events{/privacy}","received_events_url":"https://api.github.com/users/albheim/received_events","type":"User","site_admin":false},"body":"Not completed, just want to see how it works","created_at":"2015-03-24T12:28:36Z","updated_at":"2015-03-24T12:28:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fsek/web/pulls/112/commits","review_comments_url":"https://api.github.com/repos/fsek/web/pulls/112/comments","review_comment_url":"https://api.github.com/repos/fsek/web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/fsek/web/issues/112/comments","statuses_url":"https://api.github.com/repos/fsek/web/statuses/afc2acb45ef26be9fc63d9e9059a8316e53f1576","head":{"label":"fsek:event_anmalan","ref":"event_anmalan","sha":"afc2acb45ef26be9fc63d9e9059a8316e53f1576","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-03-23T19:11:50Z","pushed_at":"2015-03-24T12:28:36Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":209884,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":48,"forks":1,"open_issues":48,"watchers":1,"default_branch":"master"}},"base":{"label":"fsek:master","ref":"master","sha":"d97a079ed86b063724a47cf97f7dfa2730747799","user":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"repo":{"id":27583674,"name":"web","full_name":"fsek/web","owner":{"login":"fsek","id":10084654,"avatar_url":"https://avatars.githubusercontent.com/u/10084654?v=3","gravatar_id":"","url":"https://api.github.com/users/fsek","html_url":"https://github.com/fsek","followers_url":"https://api.github.com/users/fsek/followers","following_url":"https://api.github.com/users/fsek/following{/other_user}","gists_url":"https://api.github.com/users/fsek/gists{/gist_id}","starred_url":"https://api.github.com/users/fsek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fsek/subscriptions","organizations_url":"https://api.github.com/users/fsek/orgs","repos_url":"https://api.github.com/users/fsek/repos","events_url":"https://api.github.com/users/fsek/events{/privacy}","received_events_url":"https://api.github.com/users/fsek/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/fsek/web","description":"F-sektionens hemsida","fork":false,"url":"https://api.github.com/repos/fsek/web","forks_url":"https://api.github.com/repos/fsek/web/forks","keys_url":"https://api.github.com/repos/fsek/web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fsek/web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fsek/web/teams","hooks_url":"https://api.github.com/repos/fsek/web/hooks","issue_events_url":"https://api.github.com/repos/fsek/web/issues/events{/number}","events_url":"https://api.github.com/repos/fsek/web/events","assignees_url":"https://api.github.com/repos/fsek/web/assignees{/user}","branches_url":"https://api.github.com/repos/fsek/web/branches{/branch}","tags_url":"https://api.github.com/repos/fsek/web/tags","blobs_url":"https://api.github.com/repos/fsek/web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fsek/web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fsek/web/git/refs{/sha}","trees_url":"https://api.github.com/repos/fsek/web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fsek/web/statuses/{sha}","languages_url":"https://api.github.com/repos/fsek/web/languages","stargazers_url":"https://api.github.com/repos/fsek/web/stargazers","contributors_url":"https://api.github.com/repos/fsek/web/contributors","subscribers_url":"https://api.github.com/repos/fsek/web/subscribers","subscription_url":"https://api.github.com/repos/fsek/web/subscription","commits_url":"https://api.github.com/repos/fsek/web/commits{/sha}","git_commits_url":"https://api.github.com/repos/fsek/web/git/commits{/sha}","comments_url":"https://api.github.com/repos/fsek/web/comments{/number}","issue_comment_url":"https://api.github.com/repos/fsek/web/issues/comments{/number}","contents_url":"https://api.github.com/repos/fsek/web/contents/{+path}","compare_url":"https://api.github.com/repos/fsek/web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fsek/web/merges","archive_url":"https://api.github.com/repos/fsek/web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fsek/web/downloads","issues_url":"https://api.github.com/repos/fsek/web/issues{/number}","pulls_url":"https://api.github.com/repos/fsek/web/pulls{/number}","milestones_url":"https://api.github.com/repos/fsek/web/milestones{/number}","notifications_url":"https://api.github.com/repos/fsek/web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fsek/web/labels{/name}","releases_url":"https://api.github.com/repos/fsek/web/releases{/id}","created_at":"2014-12-05T09:13:19Z","updated_at":"2015-03-23T19:11:50Z","pushed_at":"2015-03-24T12:28:36Z","git_url":"git://github.com/fsek/web.git","ssh_url":"git@github.com:fsek/web.git","clone_url":"https://github.com/fsek/web.git","svn_url":"https://github.com/fsek/web","homepage":"http://fsektionen.se","size":209884,"stargazers_count":1,"watchers_count":1,"language":"HTML","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":48,"forks":1,"open_issues":48,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fsek/web/pulls/112"},"html":{"href":"https://github.com/fsek/web/pull/112"},"issue":{"href":"https://api.github.com/repos/fsek/web/issues/112"},"comments":{"href":"https://api.github.com/repos/fsek/web/issues/112/comments"},"review_comments":{"href":"https://api.github.com/repos/fsek/web/pulls/112/comments"},"review_comment":{"href":"https://api.github.com/repos/fsek/web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/fsek/web/pulls/112/commits"},"statuses":{"href":"https://api.github.com/repos/fsek/web/statuses/afc2acb45ef26be9fc63d9e9059a8316e53f1576"}}}}