Class: Apidae::ProjectsController
Instance Method Summary
collapse
#apidae_user, #check_user_data!, #user_has_data?, #user_is_admin?
Instance Method Details
#create ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'app/controllers/apidae/projects_controller.rb', line 21
def create
if Project.find_by_apidae_id(project_params[:apidae_id])
@project = Project.find_by_apidae_id(project_params[:apidae_id])
update_project
else
@project = Project.new(project_params)
if @project.save
referrer = params[:redirect_to] || session.delete(:referrer) || projects_url
redirect_to (referrer + "?apidae_project_id=#{@project.id}"), notice: 'Le projet a bien été créé'
else
flash.now[:alert] = "Une erreur s'est produite lors la création du projet"
render :new
end
end
end
|
#destroy ⇒ Object
45
46
47
48
|
# File 'app/controllers/apidae/projects_controller.rb', line 45
def destroy
@project.destroy
redirect_to request.referrer, notice: 'Le projet a bien été supprimé.'
end
|
#edit ⇒ Object
37
38
39
|
# File 'app/controllers/apidae/projects_controller.rb', line 37
def edit
session[:referrer] = request.referrer.split('?').first unless request.referrer.blank?
end
|
#index ⇒ Object
8
9
10
11
12
13
14
|
# File 'app/controllers/apidae/projects_controller.rb', line 8
def index
if user_is_admin?
@projects = Project.all
else
@projects = Project.where(apidae_id: apidae_user.apidae_projects_ids)
end
end
|
#new ⇒ Object
16
17
18
19
|
# File 'app/controllers/apidae/projects_controller.rb', line 16
def new
session[:referrer] = request.referrer.split('?').first unless request.referrer.blank?
@project = Project.new(locales: [DEFAULT_LOCALE], versions: [DEFAULT_VERSION])
end
|
#update ⇒ Object
41
42
43
|
# File 'app/controllers/apidae/projects_controller.rb', line 41
def update
update_project
end
|