diff --git a/app/assets/javascripts/alerts.js.coffee b/app/assets/javascripts/alerts.js.coffee new file mode 100644 index 0000000..7615679 --- /dev/null +++ b/app/assets/javascripts/alerts.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/alerts.css.scss b/app/assets/stylesheets/alerts.css.scss new file mode 100644 index 0000000..0969a3d --- /dev/null +++ b/app/assets/stylesheets/alerts.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the Alerts controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss new file mode 100644 index 0000000..6ec6a8f --- /dev/null +++ b/app/assets/stylesheets/scaffolds.css.scss @@ -0,0 +1,69 @@ +body { + background-color: #fff; + color: #333; + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +p, ol, ul, td { + font-family: verdana, arial, helvetica, sans-serif; + font-size: 13px; + line-height: 18px; +} + +pre { + background-color: #eee; + padding: 10px; + font-size: 11px; +} + +a { + color: #000; + &:visited { + color: #666; + } + &:hover { + color: #fff; + background-color: #000; + } +} + +div { + &.field, &.actions { + margin-bottom: 10px; + } +} + +#notice { + color: green; +} + +.field_with_errors { + padding: 2px; + background-color: red; + display: table; +} + +#error_explanation { + width: 450px; + border: 2px solid red; + padding: 7px; + padding-bottom: 0; + margin-bottom: 20px; + background-color: #f0f0f0; + h2 { + text-align: left; + font-weight: bold; + padding: 5px 5px 5px 15px; + font-size: 12px; + margin: -7px; + margin-bottom: 0px; + background-color: #c00; + color: #fff; + } + ul li { + font-size: 12px; + list-style: square; + } +} diff --git a/app/controllers/alerts_controller.rb b/app/controllers/alerts_controller.rb new file mode 100644 index 0000000..d5bd605 --- /dev/null +++ b/app/controllers/alerts_controller.rb @@ -0,0 +1,83 @@ +class AlertsController < ApplicationController + # GET /alerts + # GET /alerts.json + def index + @alerts = Alert.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @alerts } + end + end + + # GET /alerts/1 + # GET /alerts/1.json + def show + @alert = Alert.find(params[:id]) + + respond_to do |format| + format.html # show.html.erb + format.json { render json: @alert } + end + end + + # GET /alerts/new + # GET /alerts/new.json + def new + @alert = Alert.new + + respond_to do |format| + format.html # new.html.erb + format.json { render json: @alert } + end + end + + # GET /alerts/1/edit + def edit + @alert = Alert.find(params[:id]) + end + + # POST /alerts + # POST /alerts.json + def create + @alert = Alert.new(params[:alert]) + + respond_to do |format| + if @alert.save + format.html { redirect_to @alert, notice: 'Alert was successfully created.' } + format.json { render json: @alert, status: :created, location: @alert } + else + format.html { render action: "new" } + format.json { render json: @alert.errors, status: :unprocessable_entity } + end + end + end + + # PUT /alerts/1 + # PUT /alerts/1.json + def update + @alert = Alert.find(params[:id]) + + respond_to do |format| + if @alert.update_attributes(params[:alert]) + format.html { redirect_to @alert, notice: 'Alert was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: "edit" } + format.json { render json: @alert.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /alerts/1 + # DELETE /alerts/1.json + def destroy + @alert = Alert.find(params[:id]) + @alert.destroy + + respond_to do |format| + format.html { redirect_to alerts_url } + format.json { head :no_content } + end + end +end diff --git a/app/helpers/alerts_helper.rb b/app/helpers/alerts_helper.rb new file mode 100644 index 0000000..20f5b50 --- /dev/null +++ b/app/helpers/alerts_helper.rb @@ -0,0 +1,2 @@ +module AlertsHelper +end diff --git a/app/models/alert.rb b/app/models/alert.rb new file mode 100644 index 0000000..0d9828e --- /dev/null +++ b/app/models/alert.rb @@ -0,0 +1,3 @@ +class Alert < ActiveRecord::Base + attr_accessible :alerted, :course, :department, :user_id +end diff --git a/app/views/alerts/_form.html.erb b/app/views/alerts/_form.html.erb new file mode 100644 index 0000000..d5ed1b0 --- /dev/null +++ b/app/views/alerts/_form.html.erb @@ -0,0 +1,32 @@ +<%= form_for @alert, :html => { :class => 'form-horizontal' } do |f| %> +
<%= model_class.human_attribute_name(:id) %> | +<%= model_class.human_attribute_name(:user_id) %> | +<%= model_class.human_attribute_name(:department) %> | +<%= model_class.human_attribute_name(:course) %> | +<%= model_class.human_attribute_name(:alerted) %> | +<%= model_class.human_attribute_name(:created_at) %> | +<%=t '.actions', :default => t("helpers.actions") %> | +
---|---|---|---|---|---|---|
<%= link_to alert.id, alert_path(alert) %> | +<%= alert.user_id %> | +<%= alert.department %> | +<%= alert.course %> | +<%= alert.alerted %> | +<%=l alert.created_at %> | ++ <%= link_to t('.edit', :default => t("helpers.links.edit")), + edit_alert_path(alert), :class => 'btn btn-mini' %> + <%= link_to t('.destroy', :default => t("helpers.links.destroy")), + alert_path(alert), + :method => :delete, + :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, + :class => 'btn btn-mini btn-danger' %> + | +