Code cleanup.

This commit is contained in:
Martin Edenhofer 2012-04-10 16:30:10 +02:00
parent a77f3b6435
commit b870b8208b
9 changed files with 21 additions and 119 deletions

View file

@ -40,9 +40,6 @@ Config.NavBar['AdminTrigger'] = { prio: 3000, parent: '#admin', name: 'Trigger',
Config.NavBar['AdminScheduler'] = { prio: 3500, parent: '#admin', name: 'Scheduler', target: '#scheduler', role: ['Admin'] }
Config.NavBar['Note'] = { prio: 1500, parent: '', name: 'Notes', target: '#notes', role: ['Notes'] }
#Config.NavBar['Post'] = { prio: 1600, parent: '', name: 'Posts', target: '#posts', role: ['Agent'] }
Config.NavBar['Setting'] = { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }
Config.NavBar['SettingSystem'] = { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', role: ['Admin'] }
Config.NavBar['SettingSecurity'] = { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', role: ['Admin'] }

View file

@ -40,13 +40,6 @@
<li><a href="#login">Sign in</a></li>
</ul>
<% end %>
<!--
<ul class="nav">
<li><a href="#notes">Notes</a></li>
<li><a href="#register">Register</a></li>
<li><a href="#login">Login</a></li>
</ul>
-->
</div>
</div>
</div>

View file

@ -1,7 +1,7 @@
class ApplicationController < ActionController::Base
include UserInfo
protect_from_forgery
http_basic_authenticate_with :name => "test", :password => "ttt"
# http_basic_authenticate_with :name => "test", :password => "ttt"
helper_method :current_user, :authentication_check
@ -128,7 +128,6 @@ class ApplicationController < ActionController::Base
logger.debug 'authentication_check'
# check http basic auth
if false
authenticate_with_http_basic do |user, password|
logger.debug 'http basic auth check'
# logger.debug session.inspect
@ -149,11 +148,6 @@ class ApplicationController < ActionController::Base
# message = 'login required'
if message != ''
respond_to do |format|
# format.html {
# flash[:notice] = "You're not logged in!"
# store_location
# redirect_to :login
# }
format.json {
render :json => { :error => message }, :status => :unauthorized
}
@ -163,10 +157,9 @@ class ApplicationController < ActionController::Base
# return true
# request_http_basic_authentication
end
end
logger.debug 'session check'
logger.debug session.inspect
# logger.debug 'session check'
# logger.debug session.inspect
# session[:user_id] = 2
if !session[:user_id]
# = userdata.id
@ -175,11 +168,6 @@ class ApplicationController < ActionController::Base
logger.debug session.inspect
message = 'no valid session, user_id'
respond_to do |format|
# format.html {
# flash[:notice] = "You're not logged in!"
# store_location
# redirect_to :login
# }
format.json {
render :json => { :error => message }, :status => :unauthorized
}

View file

@ -1,86 +0,0 @@
class NotesController < ApplicationController
before_filter :authentication_check
# GET /notes
# GET /notes.json
def index
@notes = Note.find(:all, :order => "updated_at ASC")
# @notes = Note.all
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @notes }
end
end
# GET /notes/1
# GET /notes/1.json
def show
@note = Note.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @note }
end
end
# GET /notes/new
# GET /notes/new.json
def new
@note = Note.new
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @note }
end
end
# GET /notes/1/edit
def edit
@note = Note.find(params[:id])
end
# POST /notes
# POST /notes.json
def create
@note = Note.new(params[:note])
respond_to do |format|
if @note.save
format.html { redirect_to @note, :notice => 'Note was successfully created.' }
format.json { render :json => @note, :status => :created }
else
format.html { render :action => "new" }
format.json { render :json => @note.errors, :status => :unprocessable_entity }
end
end
end
# PUT /notes/1
# PUT /notes/1.json
def update
@note = Note.find(params[:id])
respond_to do |format|
if @note.update_attributes(params[:note])
format.html { redirect_to @note, :notice => 'Note was successfully updated.' }
format.json { render :json => @note, :status => :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @note.errors, :status => :unprocessable_entity }
end
end
end
# DELETE /notes/1
# DELETE /notes/1.json
def destroy
@note = Note.find(params[:id])
@note.destroy
respond_to do |format|
format.html { redirect_to notes_url }
format.json { head :ok }
end
end
end

View file

@ -135,10 +135,10 @@ class SessionsController < ApplicationController
default_collection['TicketPriority'] = Ticket::Priority.all
default_collection['TicketArticleType'] = Ticket::Article::Type.all
default_collection['TicketArticleSender'] = Ticket::Article::Sender.all
default_collection['Forum'] = Forum.all
default_collection['ForumCategory'] = Forum::Category.all
default_collection['ForumCategoryType'] = Forum::Category::Type.all
default_collection['ForumPrivacy'] = Forum::Privacy.all
default_collection['Network'] = Network.all
default_collection['NetworkCategory'] = Network::Category.all
default_collection['NetworkCategoryType'] = Network::Category::Type.all
default_collection['NetworkPrivacy'] = Network::Privacy.all
return default_collection
end
end

View file

@ -1,2 +0,0 @@
module NotesHelper
end

View file

@ -1,5 +1,8 @@
# Load the rails application
require File.expand_path('../application', __FILE__)
# load module used to get current user for active recorde observer
require 'user_info'
# Initialize the rails application
Zammad::Application.initialize!

View file

@ -70,7 +70,7 @@ class CreateNetwork < ActiveRecord::Migration
t.column :created_by_id, :integer, :null => false
t.timestamps
end
add_index :network_category_subscriptions, [:network_categories_id, :created_by_id], :unique => true, :name => 'index_network_category_subscriptions_on_network_categories_i_and_c'
add_index :network_category_subscriptions, [:network_categories_id, :created_by_id], :unique => true, :name => 'index_network_category_subscriptions_on_network_c_i_and_c'
create_table :network_item_subscriptions do |t|

9
lib/user_info.rb Normal file
View file

@ -0,0 +1,9 @@
module UserInfo
def current_user_id
Thread.current[:user_id]
end
def self.current_user_id=(user_id)
Thread.current[:user_id] = user_id
end
end