Description:
added user settings git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@37 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r13:a663af8c2813 - - 15 files changed: 163 inserted, 108 deleted

@@ -0,0 +1,15
1 + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 +
4 + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 + <head>
6 + <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7 + <title>Grader!</title>
8 + <%= stylesheet_link_tag 'application' %>
9 + </head>
10 + <body>
11 +
12 + <%= yield %>
13 +
14 + </body>
15 + </html>
@@ -0,0 +1,92
1 + # This file is auto-generated from the current state of the database. Instead of editing this file,
2 + # please use the migrations feature of ActiveRecord to incrementally modify your database, and
3 + # then regenerate this schema definition.
4 + #
5 + # Note that this schema.rb definition is the authoritative source for your database schema. If you need
6 + # to create the application database on another system, you should be using db:schema:load, not running
7 + # all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
8 + # you'll amass, the slower it'll run and the greater likelihood for issues).
9 + #
10 + # It's strongly recommended to check this file into your version control system.
11 +
12 + ActiveRecord::Schema.define(:version => 11) do
13 +
14 + create_table "languages", :force => true do |t|
15 + t.string "name", :limit => 10
16 + t.string "pretty_name"
17 + t.string "ext", :limit => 10
18 + end
19 +
20 + create_table "problems", :force => true do |t|
21 + t.string "name", :limit => 30
22 + t.string "full_name"
23 + t.integer "full_score"
24 + t.date "date_added"
25 + t.boolean "available"
26 + end
27 +
28 + create_table "rights", :force => true do |t|
29 + t.string "name"
30 + t.string "controller"
31 + t.string "action"
32 + end
33 +
34 + create_table "rights_roles", :id => false, :force => true do |t|
35 + t.integer "right_id"
36 + t.integer "role_id"
37 + end
38 +
39 + add_index "rights_roles", ["role_id"], :name => "index_rights_roles_on_role_id"
40 +
41 + create_table "roles", :force => true do |t|
42 + t.string "name"
43 + end
44 +
45 + create_table "roles_users", :id => false, :force => true do |t|
46 + t.integer "role_id"
47 + t.integer "user_id"
48 + end
49 +
50 + add_index "roles_users", ["user_id"], :name => "index_roles_users_on_user_id"
51 +
52 + create_table "sessions", :force => true do |t|
53 + t.string "session_id"
54 + t.text "data"
55 + t.datetime "updated_at"
56 + end
57 +
58 + add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
59 + add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
60 +
61 + create_table "submissions", :force => true do |t|
62 + t.integer "user_id"
63 + t.integer "problem_id"
64 + t.integer "language_id"
65 + t.text "source"
66 + t.binary "binary"
67 + t.datetime "submitted_at"
68 + t.datetime "compiled_at"
69 + t.text "compiler_message"
70 + t.datetime "graded_at"
71 + t.integer "points"
72 + t.text "grader_comment"
73 + end
74 +
75 + add_index "submissions", ["user_id", "problem_id"], :name => "index_submissions_on_user_id_and_problem_id"
76 +
77 + create_table "tasks", :force => true do |t|
78 + t.integer "submission_id"
79 + t.datetime "created_at"
80 + end
81 +
82 + create_table "users", :force => true do |t|
83 + t.string "login", :limit => 10
84 + t.string "full_name"
85 + t.string "hashed_password"
86 + t.string "salt", :limit => 5
87 + t.string "alias"
88 + end
89 +
90 + add_index "users", ["login"], :name => "index_users_on_login", :unique => true
91 +
92 + end
@@ -0,0 +1,2
1 + require 'haml'
2 + Haml.init_rails(binding)
@@ -10,6 +10,7
10 10 end
11 11
12 12 def login
13 + MainController.layout 'login'
13 14 reset_session
14 15 end
15 16
@@ -1,2 +1,27
1 1 class UsersController < ApplicationController
2 +
3 + before_filter :authenticate
4 +
5 + verify :method => :post, :only => [:chg_passwd],
6 + :redirect_to => { :action => :index }
7 +
8 + in_place_edit_for :user, :full_name
9 + in_place_edit_for :user, :alias
10 +
11 + def index
12 + @user = User.find(session[:user_id])
13 + end
14 +
15 + def chg_passwd
16 + user = User.find(session[:user_id])
17 + user.password = params[:passwd]
18 + user.password_confirmation = params[:passwd_verify]
19 + if user.save
20 + flash[:notice] = 'password changed'
21 + else
22 + flash[:notice] = 'Error: password changing failed'
23 + end
24 + redirect_to :action => 'index'
25 + end
26 +
2 27 end
@@ -1,3 +1,24
1 1 # Methods added to this helper will be available to all templates in the application.
2 2 module ApplicationHelper
3 +
4 + def user_options
5 + options = ''
6 + user = User.find(session[:user_id])
7 + if user.admin?
8 + options = options + ' ' +
9 + (link_to_unless_current '[Problem admin]',
10 + :controller => 'problems', :action => 'index')
11 + options = options + ' ' +
12 + (link_to_unless_current '[User admin]',
13 + :controller => 'user_admin', :action => 'index')
14 + end
15 + options += link_to_unless_current '[Main]',
16 + :controller => 'main', :action => 'list'
17 + options += link_to_unless_current '[Settings]',
18 + :controller => 'users', :action => 'index'
19 + options = options + ' ' +
20 + link_to('[Log out]', {:controller => 'main', :action => 'login'})
21 + options
22 + end
23 +
3 24 end
@@ -1,21 +1,5
1 1 module MainHelper
2 2
3 - def user_options
4 - options = ''
5 - user = User.find(session[:user_id])
6 - if user.admin?
7 - options = options + ' ' +
8 - link_to('[Problem admin]',
9 - {:controller => 'problems', :action => 'index'})
10 - options = options + ' ' +
11 - link_to('[User admin]',
12 - {:controller => 'user_admin', :action => 'index'})
13 - end
14 - options = options + ' ' +
15 - link_to('[Log out]', {:controller => 'main', :action => 'login'})
16 - options
17 - end
18 -
19 3 def format_short_time(time)
20 4 now = Time.now
21 5 st = ''
@@ -6,9 +6,16
6 6 <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7 7 <title>Grader!</title>
8 8 <%= stylesheet_link_tag 'application' %>
9 + <%= javascript_include_tag :defaults %>
9 10 </head>
10 11 <body>
11 12
13 + <div class="usermenu">
14 + <%= user_options %>
15 + </div>
16 +
17 + <p style="color: green"><%= flash[:notice] %></p>
18 +
12 19 <%= yield %>
13 20
14 21 </body>
@@ -1,10 +1,6
1 1 <h1>Hello <%=h @user.full_name %></h1>
2 2 (<%= Time.new %>)
3 3
4 - <div class="usermenu">
5 - <%= user_options %>
6 - </div>
7 -
8 4 <div class="submitbox">
9 5 <% form_tag({:action => 'submit'}, :multipart => true) do %>
10 6 Problem: <%= select 'submission', 'problem_id',
deleted file
deleted file
deleted file
deleted file
deleted file
deleted file
You need to be logged in to leave comments. Login now