['admin.competition.delete': "/admin/competition/delete/:competition_id"]: controller "admin.competition.delete"
['admin.competition.add_problem': "/admin/competition/add_problem"]: controller "admin.competition.add_problem"
['admin.competition.delete_problem': "/admin/competition/delete_problem"]: controller "admin.competition.delete_problem"
+ ['admin.competition.activate': "/admin/competition/activate/:competition_id"]: controller "admin.competition.activate"
[test: '/test']: =>
user = Users\find 5
@flow 'csrf_validate'
assert_valid @params, {
- { "username", exists: true, min_length: 2 }
+ { "username", exists: true, min_length: 2, matches_pattern: "%S+" }
{ "nickname", exists: true, min_length: 2 }
{ "email", exists: true, min_length: 4, matches_pattern: "%S+@%S+%.%S+" }
{ "password", exists: true, min_length: 2 }
--- /dev/null
+import make_controller from require "controllers.controller"
+import assert_valid from require "lapis.validate"
+import capture_errors, capture_errors_json, yield_error from require 'lapis.application'
+import Competitions, Problems, CompetitionProblems from require 'models'
+db = require 'lapis.db'
+
+make_controller
+ middleware: { 'logged_in', 'admin_required' }
+
+ get: capture_errors_json =>
+ assert_valid @params, {
+ { "competition_id", exists: true }
+ }
+
+ comp = Competitions\find @params.competition_id
+ unless comp
+ yield_error "Competition not found"
+
+ db.query 'UPDATE competitions SET active=FALSE WHERE 1=1;'
+
+ comp\update {
+ active: true
+ }
+
+ redirect_to: @url_for "admin.competition"
\ No newline at end of file
@problems = Problems\select!
- return {
- layout: require 'views.partials.admin_layout'
- render: 'admin.problem.new'
- }
+ render: 'admin.problem.new'
post: capture_errors =>
@flow 'csrf_validate'
yield_error "Job not found"
render: "admin.submission.edit"
-
- post: capture_errors_json =>
- json: { 'success': true }
div class: 'option-line', ->
span comp.name
div class: 'button-list', ->
+ a href: (@url_for "admin.competition.activate", { competition_id: comp.id }), "Make active"
a href: (@url_for "admin.competition.edit", { competition_id: comp.id }), "Edit"
a href: (@url_for "admin.competition.delete", { competition_id: comp.id}), 'Delete'
div class: 'box', ->
+ if comp.active
+ div class: 'highlight pad-12', ->
+ span 'Active'
+
div class: 'highlight pad-12 split-lr', ->
span 'Start time'
span comp.start
a { 'data-problem-delete': problem.short_name }, 'Delete'
div class: 'box', ->
+ div class: 'highlight pad-12 split-lr', ->
+ span "Id:"
+ span "#{problem.id}"
div class: 'highlight pad-12 split-lr', ->
span "Short name:"
span "#{problem.short_name}"
span 'Status:'
span Jobs.statuses\to_name job.status
div class: 'highlight pad-12 split-lr', ->
- span 'Username:'
- span job\get_user!.username
+ span 'User id:'
+ span job.user_id
div class: 'highlight pad-12 split-lr', ->
- span 'Problem:'
- span job\get_problem!.short_name
+ span 'Problem id:'
+ span job.problem_id
div class: 'highlight pad-12 split-lr', ->
span 'Language:'
span job.lang
button { 'data-user-reset-password': user.username }, 'Reset password'
button { 'data-user-delete': user.username }, 'Delete'
div class: 'box', ->
+ div class: 'highlight pad-12 split-lr', ->
+ span "Id:"
+ span "#{user.id}"
div class: 'highlight pad-12 split-lr', ->
span "Nickname:"
span "#{user.nickname}"
```
module.exports = (app) ->
- app.get '/', (req, res) ->
- res.json {
- test: 'This is test data'
- }
-
app.post '/request', (req, res) ->
cases = JSON.parse req.body.test_cases
job_id = uuid()