my_profile and admin/ordergroups.

This commit is contained in:
benni 2011-06-10 01:36:04 +02:00
parent a787b3cf24
commit c173cf4a6a
14 changed files with 92 additions and 225 deletions

View file

@ -1,68 +1,29 @@
class Admin::OrdergroupsController < Admin::BaseController class Admin::OrdergroupsController < Admin::BaseController
inherit_resources
def index def index
@ordergroups = Ordergroup.order(:name.asc)
# if somebody uses the search field:
unless params[:query].blank?
@ordergroups = @ordergroups.where(:name.matches => "%#{params[:query]}%")
end
# sort by nick, thats default
if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100) if (params[:per_page] && params[:per_page].to_i > 0 && params[:per_page].to_i <= 100)
@per_page = params[:per_page].to_i @per_page = params[:per_page].to_i
else else
@per_page = 20 @per_page = 20
end end
# if the search field is used @ordergroups = @ordergroups.paginate(:page => params[:page], :per_page => @per_page)
conditions = "name LIKE '%#{params[:query]}%'" unless params[:query].nil?
@total = Ordergroup.without_deleted.count(:conditions => conditions )
@ordergroups = Ordergroup.without_deleted.paginate(:conditions => conditions, :page => params[:page],
:per_page => @per_page, :order => 'name')
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.haml
format.js { render :partial => "ordergroups" } format.js { render :layout => false } # index.js.erb
end end
end end
def show
@ordergroup = Ordergroup.find(params[:id])
end
def new
@ordergroup = Ordergroup.new
end
def edit
@ordergroup = Ordergroup.find(params[:id])
end
def create
@ordergroup = Ordergroup.new(params[:ordergroup])
@ordergroup.account_updated = Time.now
if @ordergroup.save
flash[:notice] = 'Ordergroup was successfully created.'
redirect_to([:admin, @ordergroup])
else
render :action => "new"
end
end
def update
@ordergroup = Ordergroup.find(params[:id])
if @ordergroup.update_attributes(params[:ordergroup])
flash[:notice] = 'Ordergroup was successfully updated.'
redirect_to([:admin, @ordergroup])
else
render :action => "edit"
end
end
def destroy
@ordergroup = Ordergroup.find(params[:id])
@ordergroup.destroy
redirect_to(admin_ordergroups_url)
end
def memberships def memberships
@group = Ordergroup.find(params[:id]) @group = Ordergroup.find(params[:id])
end end

View file

@ -23,49 +23,4 @@ class Admin::UsersController < Admin::BaseController
format.js { render :layout => false } # index.js.erb format.js { render :layout => false } # index.js.erb
end end
end end
# def show
# @user = User.find(params[:id])
# end
#
# def new
# @user = User.new
# end
#
# def create
# @user = User.new(params[:user])
# if @user.save
# flash[:notice] = 'Benutzerin wurde erfolgreich angelegt.'
# redirect_to admin_users_path
# else
# render :action => 'new'
# end
# end
#
# def edit
# @user = User.find(params[:id])
# end
#
# def update
# @user = User.find(params[:id])
# if @user.update_attributes(params[:user])
# flash[:notice] = 'Änderungen wurden gespeichert.'
# redirect_to [:admin, @user]
# else
# render :action => 'edit'
# end
# end
#
# def destroy
# user = User.find(params[:id])
# if user.nick == @current_user.nick
# # deny destroying logged-in-user
# flash[:error] = 'Du darfst Dich nicht selbst löschen.'
# else
# user.destroy
# flash[:notice] = 'Benutzer_in wurde gelöscht.'
# end
# redirect_to admin_users_path
# end
end end

View file

@ -4,8 +4,7 @@ class Group < ActiveRecord::Base
has_many :memberships, :dependent => :destroy has_many :memberships, :dependent => :destroy
has_many :users, :through => :memberships has_many :users, :through => :memberships
validates_length_of :name, :in => 1..25 validates :name, :presence => true, :length => {:in => 1..25}, :uniqueness => true
validates_uniqueness_of :name
validate :last_admin_on_earth, :on => :update validate :last_admin_on_earth, :on => :update
before_destroy :check_last_admin_group before_destroy :check_last_admin_group

View file

@ -1,20 +1,7 @@
- form_for [:admin, @ordergroup] do |@form| = simple_form_for [:admin, @ordergroup] do |f|
- render :layout => 'shared/group_form' do = render :layout => 'shared/group_form_fields', :locals => {:f => f} do
%div{:style => "float:right;width:40%"} = f.input :contact_person
%p = f.input :contact_phone
= @form.label :contact_person = f.input :contact_address
%br/ = f.submit
= @form.text_field :contact_person, :size => 20 = link_to "oder abbrechen", admin_ordergroups_path
%p
= @form.label :contact_phone
%br/
= @form.text_field :contact_phone, :size => 20
%p
= @form.label :contact_address
%br/
= @form.text_field :contact_address
%br{ :style => "clear:both" }
= submit_tag "Speichern"
|
= link_to "Abbrechen", admin_ordergroups_path

View file

@ -4,7 +4,7 @@
%td %td
= pagination_links_remote @ordergroups, { :update => "ordergroups" } = pagination_links_remote @ordergroups, { :update => "ordergroups" }
%td{:style => "text-align:right"} %td{:style => "text-align:right"}
- if @total > 20 - if @ordergroups.size > 20
= items_per_page :update => "ordergroups" = items_per_page :update => "ordergroups"
%table.list %table.list
%thead %thead
@ -22,7 +22,8 @@
%td= link_to_gmaps ordergroup.contact_address %td= link_to_gmaps ordergroup.contact_address
%td= ordergroup.users.size %td= ordergroup.users.size
%td %td
= link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'), memberships_admin_ordergroup_path(ordergroup) = link_to image_tag('b_users.png', :size => '16x16', :border => "0", :alt => 'Mitlglieder bearbeiten'),
= link_to(image_tag('b_edit.png', :size => "16x16", :border => "0", :alt => 'Gruppe bearbeiten'), edit_admin_ordergroup_path(ordergroup)) memberships_admin_ordergroup_path(ordergroup)
= link_to(image_tag('b_drop.png', :size => "16x16", :border => "0", :alt => 'Gruppe löschen'), [:admin, ordergroup], | = link_to icon(:edit), edit_admin_ordergroup_path(ordergroup)
:confirm => 'Willst du ' + ordergroup.name + ' wirklich löschen?', :method => :delete) | = link_to icon(:delete), [:admin, ordergroup], :confirm => "Willst du #{ordergroup.name} wirklich löschen?",
:method => :delete

View file

@ -1,4 +1,3 @@
- title "Bestellgruppe bearbeiten" - title "Bestellgruppe bearbeiten"
.edit_form{:style => "width:50em"} = render :partial => 'form'
= render :partial => 'form'

View file

@ -18,17 +18,9 @@
%h2 Gruppenübersicht %h2 Gruppenübersicht
.column_content .column_content
#group_filter #group_filter
%form{:name=>"sform", :action=>"", :style=>"display:inline;"} = form_tag admin_ordergroups_path, :method => :get, :style=>"display:inline;", :id => 'ordergroup_search',
%label{:for => 'ordergroup_name'} Suche in Name : :remote => true, 'data-submit-onchange' => true do
= text_field_tag("query", params['query'], :size => 10 ) %label{:for => 'article_name'} Suche nach Name:
= text_field_tag :query, params[:query], :size => 10
= observe_field 'query', :frequency => 2, |
:before => "Element.show('loader')", |
:success => "Element.hide('loader')", |
:update => "ordergroups", |
:url => admin_ordergroups_path, |
:with => 'query', |
:method => :get |
#ordergroups #ordergroups
= render :partial => "ordergroups" = render :partial => "ordergroups"
= link_to 'Neue Arbeits', new_admin_ordergroup_path

View file

@ -0,0 +1 @@
$('#ordergroups').html('<%= escape_javascript(render("ordergroups")) %>');

View file

@ -1,4 +1,3 @@
- title "Bestellgruppe anlegen" - title "Bestellgruppe anlegen"
.edit_form{:style => "width:50em"} = render :partial => 'form'
= render :partial => 'form'

View file

@ -1,38 +0,0 @@
<% title "Mein Profil" -%>
<p>
Hier kannst Du deine Einstellungen ändern, z.b. Deine Telphonnummer oder Dein Passwort.
</p>
<div class="left_column" style="width: 60%;">
<div class="box_title">
<h2>
<%= h @user.nick %>
<small>(Mitglied seit: <%= distance_of_time_in_words(Time.now, @user.created_on) -%>)</small>
</h2>
</div>
<div class="column_content">
<% form_for(@user, :url => { :action => 'update_profile'}) do |@form| %>
<%= render :partial => 'shared/user_form' %>
<p style="clear:both">
<%= submit_tag 'Speichern' %> | <%= link_to 'Abbrechen', :action => 'profile' %></p>
<% end %>
</div>
</div>
<div class="right_column" style="width: 35%;">
<div class="box_title">
<h2>Du bist Mitglied in folgenden Gruppen</h2>
</div>
<div class="column_content">
<% for membership in Membership.find_all_by_user_id(@user.id) %>
<p>
<%= membership.group.name %>
<% if membership.group.type != 'Ordergroup' %>
(<%= link_to _("Mitgliedschaft beenden"), { :action => 'cancel_membership', :membership_id => membership },
:confirm => _("Bist Du sicher, dass Du Deine Mitgliedschaft beenden willst?"), :method => :post %>)
<% end %>
</p>
<% end %>
</div>
</div>

View file

@ -0,0 +1,22 @@
- title "Mein Profil"
%p
Hier kannst Du deine Einstellungen ändern, z.b. Deine Telphonnummer oder Dein Passwort.
.left_column{:style => "width: 60%;"}
.box_title
%h2
= h @user.nick
%small
(Mitglied seit: #{distance_of_time_in_words(Time.now, @user.created_on)})
.column_content
- simple_form_for(@user, :url => { :action => 'update_profile'}) do |f|
= render :partial => 'shared/user_form_fields', :locals => {:f => f}
= submit_tag 'Speichern'
.right_column{:style => "width: 35%;"}
.box_title
%h2 Du bist Mitglied in folgenden Gruppen
.column_content
- for membership in Membership.find_all_by_user_id(@user.id)
%p
= membership.group.name
- if membership.group.type != 'Ordergroup'
(#{link_to _("Mitgliedschaft beenden"), { :action => 'cancel_membership', :membership_id => membership }, :confirm => _("Bist Du sicher, dass Du Deine Mitgliedschaft beenden willst?"), :method => :post})

View file

@ -0,0 +1,31 @@
= f.input :name
= f.input :description
= yield
- if f.object.is_a?(Workgroup)
%h3 Wöchentliche Jobs definieren?
= f.input :weekly_task
#weekly_task_fields
= f.input :weekday
= f.input :task_name
= f.input :task_required_users
= f.input :task_duration, :as => :select, :collection => (1..3)
= f.input :task_description
- content_for :head do
:javascript
function toggleWeeklyTaskFields() {
if ($('#workgroup_weekly_task').attr('checked') == 'checked') {
$('#weekly_task_fields div.input').show();
} else {
$('#weekly_task_fields div.input').hide();
}
}
$(function() {
toggleWeeklyTaskFields();
$('#workgroup_weekly_task').click(function() {
toggleWeeklyTaskFields();
})
})

View file

@ -1,46 +0,0 @@
<%= @form.error_messages %>
<table style="float:left;width:52%;">
<tr>
<td><%= @form.label :nick, "Benutzername" %></td>
<td><%= @form.text_field :nick %></td>
</tr>
<tr>
<td><%= @form.label :first_name, "Vorname" %></td>
<td><%= @form.text_field :first_name %></td>
</tr>
<tr>
<td><%= @form.label :last_name, "Nachname" %></td>
<td><%= @form.text_field :last_name %></td>
</tr>
<tr>
<td><%= @form.label :email, "E-Mail" %></td>
<td><%= @form.text_field :email %></td>
</tr>
<tr>
<td><%= @form.label :phone, "Telefon" %></td>
<td><%= @form.text_field :phone %></td>
</tr>
<tr>
<td/>
</tr>
<tr>
<td><%= @form.label :password, "Passwort" %></td>
<td><%= @form.password_field :password %></td>
</tr>
<tr>
<td><%= @form.label :password_confirmation, "Passwort-Wiederholung" %></td>
<td><%= @form.password_field :password_confirmation %></td>
</tr>
</table>
<table style="float:right;width:45%;">
<tr>
<td colspan="2"><b>Einstellungen:</b></td>
</tr>
<% for setting in User::setting_keys.keys -%>
<tr>
<td><label for="user[setting_attributes][<%= setting %>]"><%=h User::setting_keys[setting]%></label></td>
<td><%= check_box_tag "user[setting_attributes][#{setting}]", '1', @user.settings[setting] == '1' || @user.settings_default(setting) %></td>
</tr>
<% end -%>
</table>

View file

@ -228,6 +228,10 @@ de:
task_duration: 'Vor. Dauer in Stunden' task_duration: 'Vor. Dauer in Stunden'
task_description: 'Beschreibung' task_description: 'Beschreibung'
user_tokens: 'Mitglieder' user_tokens: 'Mitglieder'
ordergroup:
contact_person: "Kontaktperson"
contact_phone: "Telefon"
contact_address: "Adresse"
task: task:
duration: 'Dauer' duration: 'Dauer'
user_list: 'Verantwortliche' user_list: 'Verantwortliche'