Permalink
Browse files

services admin

  • Loading branch information...
1 parent 5b89fd3 commit d22b199fade884734d137601d3784b4b4db6ffad @johnrees johnrees committed Apr 5, 2012
@@ -13,4 +13,10 @@ ul#navigation {
li {
display: inline;
}
+}
+
+#admin_bar {
+background: white;
+padding: 5px;
+text-align: center;
}
@@ -3,6 +3,11 @@
$gw-column: 100px; // Column Width
$gw-gutter: 40px; // Gutter Width
+#admin_bar {
+ background: white;
+ padding: 10px;
+ text-align: center;
+}
* {
margin: 0;
@@ -0,0 +1,83 @@
+class Admin::ServicesController < Admin::BaseController
+ # GET /services
+ # GET /services.json
+ def index
+ @services = Service.all
+
+ respond_to do |format|
+ format.html # index.html.erb
+ format.json { render json: @services }
+ end
+ end
+
+ # GET /services/1
+ # GET /services/1.json
+ def show
+ @service = Service.find(params[:id])
+
+ respond_to do |format|
+ format.html # show.html.erb
+ format.json { render json: @service }
+ end
+ end
+
+ # GET /services/new
+ # GET /services/new.json
+ def new
+ @service = Service.new
+
+ respond_to do |format|
+ format.html # new.html.erb
+ format.json { render json: @service }
+ end
+ end
+
+ # GET /services/1/edit
+ def edit
+ @service = Service.find(params[:id])
+ end
+
+ # POST /services
+ # POST /services.json
+ def create
+ @service = Service.new(params[:service])
+
+ respond_to do |format|
+ if @service.save
+ format.html { redirect_to services_url, notice: 'Service was successfully created.' }
+ format.json { render json: @service, status: :created, location: @service }
+ else
+ format.html { render action: "new" }
+ format.json { render json: @service.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PUT /services/1
+ # PUT /services/1.json
+ def update
+ @service = Service.find(params[:id])
+
+ respond_to do |format|
+ if @service.update_attributes(params[:service])
+ format.html { redirect_to admin_services_url, notice: 'Service was successfully updated.' }
+ format.json { head :no_content }
+ else
+ format.html { render action: "edit" }
+ format.json { render json: @service.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /services/1
+ # DELETE /services/1.json
+ def destroy
+ @service = Service.find(params[:id])
+ @service.destroy
+
+ respond_to do |format|
+ format.html { redirect_to services_url }
+ format.json { head :no_content }
+ end
+ end
+end
@@ -20,64 +20,4 @@ def show
format.json { render json: @service }
end
end
-
- # GET /services/new
- # GET /services/new.json
- def new
- @service = Service.new
-
- respond_to do |format|
- format.html # new.html.erb
- format.json { render json: @service }
- end
- end
-
- # GET /services/1/edit
- def edit
- @service = Service.find(params[:id])
- end
-
- # POST /services
- # POST /services.json
- def create
- @service = Service.new(params[:service])
-
- respond_to do |format|
- if @service.save
- format.html { redirect_to services_url, notice: 'Service was successfully created.' }
- format.json { render json: @service, status: :created, location: @service }
- else
- format.html { render action: "new" }
- format.json { render json: @service.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # PUT /services/1
- # PUT /services/1.json
- def update
- @service = Service.find(params[:id])
-
- respond_to do |format|
- if @service.update_attributes(params[:service])
- format.html { redirect_to services_url, notice: 'Service was successfully updated.' }
- format.json { head :no_content }
- else
- format.html { render action: "edit" }
- format.json { render json: @service.errors, status: :unprocessable_entity }
- end
- end
- end
-
- # DELETE /services/1
- # DELETE /services/1.json
- def destroy
- @service = Service.find(params[:id])
- @service.destroy
-
- respond_to do |format|
- format.html { redirect_to services_url }
- format.json { head :no_content }
- end
- end
end
View
@@ -1,2 +1,5 @@
class Service < ActiveRecord::Base
+ def to_s
+ name
+ end
end
@@ -1,3 +1,5 @@
+<ul>
<% @projects.each do |project| %>
- <%= link_to project, edit_admin_project_path(project) %>
-<% end %>
+ <li><%= link_to project, edit_admin_project_path(project) %></li>
+<% end %>
+</ul>
@@ -0,0 +1,13 @@
+<%= form_for ['admin',@service] do |f| %>
+ <div>
+ <%= f.label :name %>
+ <%= f.text_field :name %>
+ </div>
+ <div>
+ <%= f.label :description %>
+ <%= f.text_area :description %>
+ </div>
+ <div>
+ <%= f.submit %>
+ </div>
+<% end %>
@@ -0,0 +1,5 @@
+<ul>
+<% @services.each do |service| %>
+ <li><%= link_to service, edit_admin_service_path(service) %></li>
+<% end %>
+</ul>
@@ -10,11 +10,13 @@
</head>
<body>
+<div id="admin_bar"><%= link_to("Preview Site", root_path) %></div>
+
<ul id="navigation">
<li><%= link_to "Projects", admin_projects_path %></li>
- <li><%= link_to "Services", admin_projects_path %></li>
+ <li><%= link_to "Services", admin_services_path %></li>
<%#= link_to "Our Ethos", admin_projects_path %>
- <li><%= link_to "Activity", admin_projects_path %></li>
+ <li>Activity<%#= link_to "Activity", admin_projects_path %></li>
<%#= link_to "Contact", admin_projects_path %>
<li><%= current_user %></li>
<li><%= link_to "Logout", logout_path %></li>
@@ -19,7 +19,8 @@
<!--[if lt IE 7]><p class=chromeframe>Your browser is <em>ancient!</em> <a href="http://browsehappy.com/">Upgrade to a different browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">install Google Chrome Frame</a> to experience this site.</p><![endif]-->
<header>
- <%#= current_user if current_user.present? %>
+ <div id="admin_bar"><%= link_to("ADMIN", admin_projects_path) if current_user.present? %></div>
+
<div class="container">
<%= link_to "Urban Lites", root_path %>
<div id="telephone_number">Call us on 0161 402 3271</div>
View
@@ -13,6 +13,7 @@
namespace :admin do
resources :projects
+ resources :services
end
resources :downloads

0 comments on commit d22b199

Please sign in to comment.