Description:
update master
Commit status:
[Not Reviewed]
References:
merge default
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r722:83f5b778c08b - - 2 files changed: 30 inserted, 2 deleted

@@ -1,66 +1,69
1 require 'net/smtp'
1 require 'net/smtp'
2
2
3 class UsersController < ApplicationController
3 class UsersController < ApplicationController
4
4
5 include MailHelperMethods
5 include MailHelperMethods
6
6
7 before_filter :authenticate, :except => [:new,
7 before_filter :authenticate, :except => [:new,
8 :register,
8 :register,
9 :confirm,
9 :confirm,
10 :forget,
10 :forget,
11 :retrieve_password]
11 :retrieve_password]
12
12
13 before_filter :verify_online_registration, :only => [:new,
13 before_filter :verify_online_registration, :only => [:new,
14 :register,
14 :register,
15 :forget,
15 :forget,
16 :retrieve_password]
16 :retrieve_password]
17 before_filter :authenticate, :profile_authorization, only: [:profile]
17 before_filter :authenticate, :profile_authorization, only: [:profile]
18
18
19 + before_filter :admin_authorization, only: [:stat, :toggle_activate, :toggle_enable]
20 +
21 +
19 verify :method => :post, :only => [:chg_passwd],
22 verify :method => :post, :only => [:chg_passwd],
20 :redirect_to => { :action => :index }
23 :redirect_to => { :action => :index }
21
24
22 #in_place_edit_for :user, :alias_for_editing
25 #in_place_edit_for :user, :alias_for_editing
23 #in_place_edit_for :user, :email_for_editing
26 #in_place_edit_for :user, :email_for_editing
24
27
25 def index
28 def index
26 if !GraderConfiguration['system.user_setting_enabled']
29 if !GraderConfiguration['system.user_setting_enabled']
27 redirect_to :controller => 'main', :action => 'list'
30 redirect_to :controller => 'main', :action => 'list'
28 else
31 else
29 @user = User.find(session[:user_id])
32 @user = User.find(session[:user_id])
30 end
33 end
31 end
34 end
32
35
33 def chg_passwd
36 def chg_passwd
34 user = User.find(session[:user_id])
37 user = User.find(session[:user_id])
35 user.password = params[:passwd]
38 user.password = params[:passwd]
36 user.password_confirmation = params[:passwd_verify]
39 user.password_confirmation = params[:passwd_verify]
37 if user.save
40 if user.save
38 flash[:notice] = 'password changed'
41 flash[:notice] = 'password changed'
39 else
42 else
40 flash[:notice] = 'Error: password changing failed'
43 flash[:notice] = 'Error: password changing failed'
41 end
44 end
42 redirect_to :action => 'index'
45 redirect_to :action => 'index'
43 end
46 end
44
47
45 def new
48 def new
46 @user = User.new
49 @user = User.new
47 render :action => 'new', :layout => 'empty'
50 render :action => 'new', :layout => 'empty'
48 end
51 end
49
52
50 def register
53 def register
51 if(params[:cancel])
54 if(params[:cancel])
52 redirect_to :controller => 'main', :action => 'login'
55 redirect_to :controller => 'main', :action => 'login'
53 return
56 return
54 end
57 end
55 @user = User.new(user_params)
58 @user = User.new(user_params)
56 @user.password_confirmation = @user.password = User.random_password
59 @user.password_confirmation = @user.password = User.random_password
57 @user.activated = false
60 @user.activated = false
58 if (@user.valid?) and (@user.save)
61 if (@user.valid?) and (@user.save)
59 if send_confirmation_email(@user)
62 if send_confirmation_email(@user)
60 render :action => 'new_splash', :layout => 'empty'
63 render :action => 'new_splash', :layout => 'empty'
61 else
64 else
62 @admin_email = GraderConfiguration['system.admin_email']
65 @admin_email = GraderConfiguration['system.admin_email']
63 render :action => 'email_error', :layout => 'empty'
66 render :action => 'email_error', :layout => 'empty'
64 end
67 end
65 else
68 else
66 @user.errors.add(:base,"Email cannot be blank") if @user.email==''
69 @user.errors.add(:base,"Email cannot be blank") if @user.email==''
@@ -1,100 +1,125
1 %h2 Live submit
1 %h2 Live submit
2 %br
2 %br
3
3
4 %textarea#text_sourcecode{style: "display:none"}~ @source
4 %textarea#text_sourcecode{style: "display:none"}~ @source
5 .container
5 .container
6 .row
6 .row
7 .col-md-12
7 .col-md-12
8 .alert.alert-info
8 .alert.alert-info
9 Write your code in the following box, choose language, and click submit button when finished
9 Write your code in the following box, choose language, and click submit button when finished
10 .row
10 .row
11 .col-md-8
11 .col-md-8
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
13 .col-md-4
13 .col-md-4
14 - # submission form
14 - # submission form
15 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
15 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
16
16
17 = hidden_field_tag 'editor_text', @source
17 = hidden_field_tag 'editor_text', @source
18 = hidden_field_tag 'submission[problem_id]', @problem.id
18 = hidden_field_tag 'submission[problem_id]', @problem.id
19 .form-group
19 .form-group
20 = label_tag "Task:"
20 = label_tag "Task:"
21 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
21 = text_field_tag 'asdf', "#{@problem.long_name}", class: 'form-control', disabled: true
22 + .form-group
23 + = label_tag "Description:"
24 + = link_to_description_if_any "[download] <span class='glyphicon glyphicon-file'></span>".html_safe, @problem
22
25
23 .form-group
26 .form-group
24 - = label_tag 'Language'
27 + = label_tag 'Language:'
25 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
28 = select_tag 'language_id', options_from_collection_for_select(Language.all, 'id', 'pretty_name', @lang_id || Language.find_by_pretty_name("Python").id || Language.first.id), class: 'form-control select', style: "width: 100px"
26 .form-group
29 .form-group
30 + .input-group
31 + %span.input-group-btn
32 + %span.btn.btn-default.btn-file
33 + Browse
34 + = file_field_tag 'load_file'
35 + = text_field_tag '' , nil, {readonly: true, class: 'form-control'}
36 + .form-group
27 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
37 = submit_tag 'Submit', class: 'btn btn-success', id: 'live_submit',
28 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
38 data: {confirm: "Submitting this source code for task #{@problem.long_name}?"}
29 - # latest submission status
39 - # latest submission status
30 .panel{class: (@submission && @submission.graded_at) ? "panel-info" : "panel-warning"}
40 .panel{class: (@submission && @submission.graded_at) ? "panel-info" : "panel-warning"}
31 .panel-heading
41 .panel-heading
32 Latest Submission Status
42 Latest Submission Status
33 = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission
43 = link_to "Refresh",get_latest_submission_status_submissions_path(@submission.user,@problem), class: "btn btn-default btn-sm", remote: true if @submission
34 .panel-body
44 .panel-body
35 %div#latest_status
45 %div#latest_status
36 - if @submission
46 - if @submission
37 = render :partial => 'submission_short',
47 = render :partial => 'submission_short',
38 :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
48 :locals => {submission: @submission, problem_name: @problem.name, problem_id: @problem.id }
39 .row
49 .row
40 .col-md-12
50 .col-md-12
41 %h2 Console
51 %h2 Console
42 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
52 %textarea#console{style: 'height: 100%; width: 100%;background-color:#000;color:#fff;font-family: consolas, monaco, "Droid Sans Mono";',rows: 20}
43
53
44 :javascript
54 :javascript
45 $(document).ready(function() {
55 $(document).ready(function() {
46 e = ace.edit("editor")
56 e = ace.edit("editor")
47 e.setValue($("#text_sourcecode").val());
57 e.setValue($("#text_sourcecode").val());
48 e.gotoLine(1);
58 e.gotoLine(1);
49 $("#language_id").trigger('change');
59 $("#language_id").trigger('change');
50 - brython();
60 +
61 + $("#load_file").on('change',function(evt) {
62 + var file = evt.target.files[0];
63 + var reader = new FileReader();
64 + reader.onload = function(theFile) {
65 + var e = ace.edit("editor")
66 + e.setValue(theFile.target.result);
67 + e.gotoLine(1);
68 + };
69 + reader.readAsText(file)
51 });
70 });
52
71
72 + //brython();
73 + });
74 +
75 +
76 +
77 +
53
78
54 %script#__main__{type:'text/python3'}
79 %script#__main__{type:'text/python3'}
55 :plain
80 :plain
56 import sys
81 import sys
57 import traceback
82 import traceback
58
83
59 from browser import document as doc
84 from browser import document as doc
60 from browser import window, alert, console
85 from browser import window, alert, console
61
86
62 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
87 _credits = """ Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands
63 for supporting Python development. See www.python.org for more information."""
88 for supporting Python development. See www.python.org for more information."""
64
89
65 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
90 _copyright = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
66 All Rights Reserved.
91 All Rights Reserved.
67
92
68 Copyright (c) 2001-2013 Python Software Foundation.
93 Copyright (c) 2001-2013 Python Software Foundation.
69 All Rights Reserved.
94 All Rights Reserved.
70
95
71 Copyright (c) 2000 BeOpen.com.
96 Copyright (c) 2000 BeOpen.com.
72 All Rights Reserved.
97 All Rights Reserved.
73
98
74 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
99 Copyright (c) 1995-2001 Corporation for National Research Initiatives.
75 All Rights Reserved.
100 All Rights Reserved.
76
101
77 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
102 Copyright (c) 1991-1995 Stichting Mathematisch Centrum, Amsterdam.
78 All Rights Reserved."""
103 All Rights Reserved."""
79
104
80 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
105 _license = """Copyright (c) 2012, Pierre Quentel pierre.quentel@gmail.com
81 All rights reserved.
106 All rights reserved.
82
107
83 Redistribution and use in source and binary forms, with or without
108 Redistribution and use in source and binary forms, with or without
84 modification, are permitted provided that the following conditions are met:
109 modification, are permitted provided that the following conditions are met:
85
110
86 Redistributions of source code must retain the above copyright notice, this
111 Redistributions of source code must retain the above copyright notice, this
87 list of conditions and the following disclaimer. Redistributions in binary
112 list of conditions and the following disclaimer. Redistributions in binary
88 form must reproduce the above copyright notice, this list of conditions and
113 form must reproduce the above copyright notice, this list of conditions and
89 the following disclaimer in the documentation and/or other materials provided
114 the following disclaimer in the documentation and/or other materials provided
90 with the distribution.
115 with the distribution.
91 Neither the name of the <ORGANIZATION> nor the names of its contributors may
116 Neither the name of the <ORGANIZATION> nor the names of its contributors may
92 be used to endorse or promote products derived from this software without
117 be used to endorse or promote products derived from this software without
93 specific prior written permission.
118 specific prior written permission.
94
119
95 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
120 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
96 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
121 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
97 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
122 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
98 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
123 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
99 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
124 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
100 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
125 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
You need to be logged in to leave comments. Login now