diff --git a/app/assets/stylesheets/error_templates.css.scss b/app/assets/stylesheets/error_templates.css.scss
deleted file mode 100644
index bbd8b05e..00000000
--- a/app/assets/stylesheets/error_templates.css.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-// Place all the styles related to the error_templates controller here.
-// They will automatically be included in application.css.
-// You can use Sass (SCSS) here: http://sass-lang.com/
diff --git a/app/controllers/error_templates_controller.rb b/app/controllers/error_templates_controller.rb
index 1007eeaf..6bf9a4f2 100644
--- a/app/controllers/error_templates_controller.rb
+++ b/app/controllers/error_templates_controller.rb
@@ -9,7 +9,7 @@ class ErrorTemplatesController < ApplicationController
# GET /error_templates
# GET /error_templates.json
def index
- @error_templates = ErrorTemplate.all
+ @error_templates = ErrorTemplate.all.order(:execution_environment_id, :name).paginate(page: params[:page])
authorize!
end
@@ -33,8 +33,8 @@ class ErrorTemplatesController < ApplicationController
# POST /error_templates
# POST /error_templates.json
def create
- authorize!
@error_template = ErrorTemplate.new(error_template_params)
+ authorize!
respond_to do |format|
if @error_template.save
@@ -81,6 +81,6 @@ class ErrorTemplatesController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def error_template_params
- params.fetch(:error_template, {})
+ params[:error_template].permit(:name, :execution_environment_id, :signature, :description, :hint)
end
end
diff --git a/app/views/error_templates/_form.html.erb b/app/views/error_templates/_form.html.erb
deleted file mode 100644
index 17371914..00000000
--- a/app/views/error_templates/_form.html.erb
+++ /dev/null
@@ -1,17 +0,0 @@
-<%= form_for(@error_template) do |f| %>
- <% if @error_template.errors.any? %>
-
-
<%= pluralize(@error_template.errors.count, "error") %> prohibited this error_template from being saved:
-
-
- <% @error_template.errors.full_messages.each do |message| %>
- - <%= message %>
- <% end %>
-
-
- <% end %>
-
-
- <%= f.submit %>
-
-<% end %>
diff --git a/app/views/error_templates/_form.html.slim b/app/views/error_templates/_form.html.slim
new file mode 100644
index 00000000..f9363155
--- /dev/null
+++ b/app/views/error_templates/_form.html.slim
@@ -0,0 +1,19 @@
+= form_for(@error_template) do |f|
+ = render('shared/form_errors', object: @error_template)
+ .form-group
+ = f.label(:name)
+ = f.text_field(:name, class: 'form-control', required: true)
+ .form-group
+ = f.label(:execution_environment_id)
+ = f.collection_select(:execution_environment_id, ExecutionEnvironment.all.order(:name), :id, :name, {include_blank: false}, class: 'form-control')
+ .form-group
+ = f.label(:signature)
+ = f.text_field(:signature, class: 'form-control')
+ .help-block == t('error_templates.hints.signature')
+ .form-group
+ = f.label(:description)
+ = f.text_field(:description, class: 'form-control')
+ .form-group
+ = f.label(:hint)
+ = f.text_field(:hint, class: 'form-control')
+ .actions = render('shared/submit_button', f: f, object: @error_template)
diff --git a/app/views/error_templates/edit.html.erb b/app/views/error_templates/edit.html.erb
deleted file mode 100644
index 0d2919e5..00000000
--- a/app/views/error_templates/edit.html.erb
+++ /dev/null
@@ -1,6 +0,0 @@
-Editing Error Template
-
-<%= render 'form' %>
-
-<%= link_to 'Show', @error_template %> |
-<%= link_to 'Back', error_templates_path %>
diff --git a/app/views/error_templates/edit.html.slim b/app/views/error_templates/edit.html.slim
new file mode 100644
index 00000000..2d12b363
--- /dev/null
+++ b/app/views/error_templates/edit.html.slim
@@ -0,0 +1,3 @@
+h1 = @error_template
+
+= render('form')
diff --git a/app/views/error_templates/index.html.erb b/app/views/error_templates/index.html.erb
deleted file mode 100644
index 65829aeb..00000000
--- a/app/views/error_templates/index.html.erb
+++ /dev/null
@@ -1,25 +0,0 @@
-<%= notice %>
-
-Listing Error Templates
-
-
-
-
- |
-
-
-
-
- <% @error_templates.each do |error_template| %>
-
- <%= link_to 'Show', error_template %> |
- <%= link_to 'Edit', edit_error_template_path(error_template) %> |
- <%= link_to 'Destroy', error_template, method: :delete, data: { confirm: 'Are you sure?' } %> |
-
- <% end %>
-
-
-
-
-
-<%= link_to 'New Error template', new_error_template_path %>
diff --git a/app/views/error_templates/index.html.slim b/app/views/error_templates/index.html.slim
new file mode 100644
index 00000000..1b028614
--- /dev/null
+++ b/app/views/error_templates/index.html.slim
@@ -0,0 +1,22 @@
+h1 = ErrorTemplate.model_name.human(count: 2)
+
+.table-responsive
+ table.sortable.table
+ thead
+ tr
+ th = t('activerecord.attributes.error_template.name')
+ th = t('activerecord.attributes.error_template.description')
+ th = t('activerecord.attributes.exercise.execution_environment')
+ th colspan=5 = t('shared.actions')
+ tbody
+ - @error_templates.each do |error_template|
+ tr
+ td = error_template.name
+ td = error_template.description
+ td = link_to(error_template.execution_environment)
+ td = link_to(t('shared.show'), error_template)
+ td = link_to(t('shared.edit'), edit_error_template_path(error_template))
+ td = link_to(t('shared.destroy'), error_template, data: {confirm: t('shared.confirm_destroy')}, method: :delete)
+
+= render('shared/pagination', collection: @error_templates)
+p = render('shared/new_button', model: ErrorTemplate)
diff --git a/app/views/error_templates/index.json.jbuilder b/app/views/error_templates/index.json.jbuilder
deleted file mode 100644
index ce85b2be..00000000
--- a/app/views/error_templates/index.json.jbuilder
+++ /dev/null
@@ -1,4 +0,0 @@
-json.array!(@error_templates) do |error_template|
- json.extract! error_template, :id
- json.url error_template_url(error_template, format: :json)
-end
diff --git a/app/views/error_templates/new.html.erb b/app/views/error_templates/new.html.erb
deleted file mode 100644
index 6b4acd06..00000000
--- a/app/views/error_templates/new.html.erb
+++ /dev/null
@@ -1,5 +0,0 @@
-New Error Template
-
-<%= render 'form' %>
-
-<%= link_to 'Back', error_templates_path %>
diff --git a/app/views/error_templates/new.html.slim b/app/views/error_templates/new.html.slim
new file mode 100644
index 00000000..eeecadc8
--- /dev/null
+++ b/app/views/error_templates/new.html.slim
@@ -0,0 +1,3 @@
+h1 = t('shared.new_model', model: ErrorTemplate.model_name.human)
+
+= render('form')
diff --git a/app/views/error_templates/show.html.erb b/app/views/error_templates/show.html.erb
deleted file mode 100644
index 9debad9b..00000000
--- a/app/views/error_templates/show.html.erb
+++ /dev/null
@@ -1,4 +0,0 @@
-<%= notice %>
-
-<%= link_to 'Edit', edit_error_template_path(@error_template) %> |
-<%= link_to 'Back', error_templates_path %>
diff --git a/app/views/error_templates/show.html.slim b/app/views/error_templates/show.html.slim
new file mode 100644
index 00000000..21843b14
--- /dev/null
+++ b/app/views/error_templates/show.html.slim
@@ -0,0 +1,10 @@
+h1
+ = @error_template
+ = render('shared/edit_button', object: @error_template)
+
+= row(label: 'error_template.name', value: @error_template.name)
+= row(label: 'exercise.execution_environment', value: link_to(@error_template.execution_environment))
+- [:signature, :description, :hint].each do |attribute|
+ = row(label: "error_template.#{attribute}", value: @error_template.send(attribute))
+
+//todo: list attributes
\ No newline at end of file
diff --git a/app/views/error_templates/show.json.jbuilder b/app/views/error_templates/show.json.jbuilder
deleted file mode 100644
index 1cbaff55..00000000
--- a/app/views/error_templates/show.json.jbuilder
+++ /dev/null
@@ -1 +0,0 @@
-json.extract! @error_template, :id, :created_at, :updated_at
diff --git a/config/locales/de.yml b/config/locales/de.yml
index d0aef588..d37992c9 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -109,6 +109,11 @@ de:
name: "Name"
file_type: "Dateityp"
content: "Code"
+ error_template:
+ name: Name
+ signature: Regulärer Ausdruck
+ description: Beschreibung
+ hint: Hinweis
models:
code_harbor_link:
one: CodeHarbor-Link
@@ -580,4 +585,6 @@ de:
estimated_time_20_to_30: "zwischen 20 und 30 Minuten"
estimated_time_more_30: "mehr als 30 Minuten"
working_time: "Geschätze Bearbeitungszeit für diese Aufgabe:"
-
+ error_templates:
+ hints:
+ signature: "Ein regulärer Ausdruck in Ruby-Syntax und ohne führende und schließende \"/\""
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 9a334697..17427a5f 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -130,6 +130,11 @@ en:
name: "Name"
file_type: "File Type"
content: "Content"
+ error_template:
+ name: Name
+ signature: Signature Regular Expression
+ description: Description
+ hint: Hint
models:
code_harbor_link:
one: CodeHarbor Link
@@ -601,3 +606,6 @@ en:
estimated_time_20_to_30: "between 20 and 30 minutes"
estimated_time_more_30: "more than 30 minutes"
working_time: "Estimated time working on this exercise:"
+ error_templates:
+ hints:
+ signature: "A regular expression in Ruby syntax without leading and trailing \"/\""