summaryrefslogtreecommitdiff
blob: e5d9a2ab93df0354c2b544e8463a03c50c800402 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# ===GLSAMaker v2
#  Copyright (C) 2009-2011 Alex Legler <a3li@gentoo.org>
#  Copyright (C) 2009 Pierre-Yves Rofes <py@gentoo.org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# For more information, see the LICENSE file.

# Index controller
class IndexController < ApplicationController
  before_filter :login_required, :except => :error
  
  def index
    @my_drafts = Glsa.find(:all, :conditions => ["status = 'draft' AND submitter = ?", current_user.id], :order => "updated_at DESC", :limit => 10)
  end
  
  def error
    if params[:type] == "user"
      render :template => 'index/error-user', :layout => 'notice'
    elsif params[:type] == "disabled"
      render :template => 'index/error-disabled', :layout => 'notice'
    elsif params[:type] == "access"
      render :template => 'index/error-access', :layout => 'notice'
    else
      render :template => 'index/error-system', :layout => 'notice'
    end
  end
  
  def about
  end
  
  def profile
    @user = current_user
    @prefs = @user.preferences
  end
  
  def update
    @user = current_user
    @prefs = @user.preferences

    preferences = {:own_ready => false, :own_comment => false, :edit => false, :new_req => false, :not_me => false}

    unless params[:preferences] == nil
      %w[own_ready own_comment edit new_req not_me].each do |notification|
        preferences[notification.to_sym] = params[:preferences][notification] == '1'
      end
    end
    
    @user.preferences[:mail] ||= {}
    @user.preferences[:mail] = preferences
    if @user.save
      flash[:notice] = "Successfully updated your profile"
      redirect_to :action => "index"
    else
      flash[:error] = "Could not update your profile"
      render :action => "profile"
    end
  end
  
end