Skip to content

Commit

Permalink
User management
Browse files Browse the repository at this point in the history
  • Loading branch information
Michal Bugno committed Mar 3, 2010
1 parent 8dbfbe5 commit 9475800
Show file tree
Hide file tree
Showing 17 changed files with 256 additions and 14 deletions.
87 changes: 87 additions & 0 deletions TODO
@@ -0,0 +1,87 @@
1. Wygodniejszy interfejs przypisywania prowadzących do zajęć, zmieniania liczby
grup przypisanych do prowadzących dane zajęcia itd. Np. przy zmienianiu liczby
grup dla danego prowadzącego powinni być widoczni wszyscy prowadzący dane
zajęcia, wszędzie powinny być informacje o liczbie jeszcze nie przypisanych grup
z danych zajęć lub o tym ile grup zostało przypisanych ponad stan faktyczny -
nie należy jednak blokować możliwości przekraczania faktycznej liczby grup przy
przypisywaniu.


2. Wprowadzenie możliwości rozliczania godzinowego, oprócz opartego na grupach.
Czyli np. możliwość przypisywania w rozliczeniu pewnym prowadzącym godzin (np.
10) za dany przedmiot. Ilości grup wyliczałyby się wtedy automatycznie.


3. Wydzielić kategorię "Inne" oprócz "semestru zimowego" i "semestru letniego".
Znajdowały by się tam wszelkie dodatkowe godziny za opiekę nad doktorantami,
koła naukowe itp., do których nie można przypisać roku, ani semestru.


4. Możliwość wybrania, w trakcie generowania raportu, na podstawie czego
obliczane są godziny: „Grup zajęciowych” lub „Grup rozliczeniowych”.


5. Sortowanie terminarza grup u admina po przedmiotach lub po prowadzących.


6. Sortowanie po każdej kolumnie w tabelkach ze spisami zajęć, przedmiotów, itd.


7. Dodanie linku edycji wszędzie, gdzie pojawiają się tabelki, czyli: "rodzaj
studiów – pokaż wszystkie", "typ zajęć – pokaż wszystkie”, "kierunki – pokaż
wszystkie", "przedmioty - pokaż wszystkie".


8. W raportach podsumowania (liczby godzin) powinny pojawiać się po każdym
semestrze oddzielnie, a na końcu jeszcze podsumowanie wszystkich godzin.


9. Oprócz powyższych informacji powinna się znaleźć tabelka (patrz Załącznik 1)
zawierająca godziny oddzielnie dla przedmiotów z EAIiE i oddzielnie spoza
EAIiE. W ramach tego podziału powinien być podział na studia stacjonarne i
niestacjonarne, a następnie podział na wykłady i ćw+lab.+proj. Dla każdego
podziału powinny być wyliczone sumy: czyli suma dla stacjonarnych na EAIiE,
dla niestacjonarnych na EAIiE itd. Natomiast godziny za egzamin powinny być w
ogóle wydzielone osobno. Odzielnie powinno się znaleźć również podsumowanie
dla godzin spoza „zajęć”, czyli opieki nad kołem naukowym itd. Dobrze by było
gdyby w ogóle tego rodzaju zestawienia można było sobie konfigurować
samodzielnie, czyli np. admin mógłby pogrupować co ma być zsumowane ponieważ
wzór tabelki może się zmienić.


10. Możliwość wygenerowania powyższej tabelki niezależnie od raportu
godzinowego.


11. Każdy element raportu można "włączyć" lub "wyłączyć" (przed wygenerowaniem
raportu).


12. W raportach "po prowadzących" w tabelce z podsumowaniem godzinowym całego
roku pozycja "Pensum" powinna się nazywać np. "Możliwe do rozliczenia w ramach
pensum" albo coś podobnego (najlepiej krótszego). W tej chwili jest to trochę
mylące bo każdy myśli, że to jest jego pensum, a nie godziny które mogą służyć
do rozliczenia pensum.


13. Powinna być możliwość zmiany semestru przy zmianie ustawień dla danych
zajęć. Ogólnie wszystko powinno dać się zmienić bez konieczności uprzedniego
usuwania danego elementu.


14. Dla wykładowcy danego przedmiotu raport o całym "jego" przedmiocie
(tzn. kto prowadzi lab., ćw. itd.).


15. Raporty powinny być eksportowane do LaTeXa (tak jak jest w tej chwili)
oraz PDFa.


16. Błąd w wersji 1.0 systemu: w grupach u prowadzącego pojawiają się już
usunięte grupy jako "do uzupełnienia".


17. Przypominanie hasła na maila.


18. Dostęp do systemu przez https.
2 changes: 2 additions & 0 deletions app/controllers/application.rb
@@ -1,4 +1,6 @@
class Application < Merb::Controller
before :ensure_authenticated

def display_title
@_title || self.title
end
Expand Down
4 changes: 3 additions & 1 deletion app/controllers/exceptions.rb
@@ -1,6 +1,8 @@
class Exceptions < Application
skip_before :ensure_authenticated

def exception
render request.exceptions.first.message
request.exceptions.first.message
end

def title
Expand Down
47 changes: 47 additions & 0 deletions app/controllers/users.rb
@@ -0,0 +1,47 @@
class Users < Application
def index
@users = [User, User.dataset, "users", [[:login, "Login"]]]
render
end

def edit
@user = User[params[:id]]
return render if request.get?
@user.update(params[:user])
redirect(url(:controller => "users"),
:message => {:notice => "Zaktualizowano!"})
rescue Sequel::ValidationFailed
self.message[:notice] = error_messages(@user)
render
end

def add
@user = User.new(params[:user] || {})
self.title = "Dodaj nowego użytkownika"
return render if request.get?
@user.save
redirect(url(:controller => "users"),
:message => {:notice => "Dodano użytkownika"})
rescue Sequel::ValidationFailed
self.message[:error] = error_messages(@user)
render
end

def delete
@user = User[params[:id]]
self.title = "Czy na pewno usunąć?"
return render if request.get?
@user.destroy
redirect(url(:controller => "users"), :message => {:notice => "Użytkownik usunięty"})
end

def title
"Użytkownicy"
end

def submenu_items
[
["dodaj", url(:controller => "users", :action => "add")],
]
end
end
4 changes: 2 additions & 2 deletions app/helpers/global_helpers.rb
Expand Up @@ -11,10 +11,10 @@ def flash_message
def menu
items = [
["home", "/", li_class("dashboard")],
["konta", url(:controller => "accounts"), li_class("accounts")],
["konta", url(:controller => "users"), li_class("users")],
["studia", url(:controller => "universities"), li_class("universities", "degrees", "lectures", "lecture_types")],
["raporty", url(:controller => "reports"), li_class("reports")],
["wyloguj", url(:controller => "session", :action => "logout"), ""],
["wyloguj", "/logout"],
]
partial "shared/menu", :menu_items => items
end
Expand Down
4 changes: 4 additions & 0 deletions app/models/user.rb
@@ -0,0 +1,4 @@
class User < BaseModel
plugin :validation_class_methods
plugin :hook_class_methods
end
3 changes: 3 additions & 0 deletions app/views/users/_form.html.erb
@@ -0,0 +1,3 @@
<%= text_field :login, :label => "Login" %>
<%= password_field :password, :label => "Hasło" %>
<%= password_field :password_confirmation, :label => "Hasło (potwierdzenie)" %>
5 changes: 5 additions & 0 deletions app/views/users/add.html.erb
@@ -0,0 +1,5 @@
<%= form_for @user, :action => url(:action => "add") do %>
<%= partial :form %>
<%= submit "Dodaj" %>
<% end =%>
3 changes: 3 additions & 0 deletions app/views/users/delete.html.erb
@@ -0,0 +1,3 @@
<%= form_for @user, :action => url(:action => "delete", :id => @user.id) do %>
<%= submit "Tak" %>
<% end =%>
5 changes: 5 additions & 0 deletions app/views/users/edit.html.erb
@@ -0,0 +1,5 @@
<%= form_for @user, :action => url(:action => "edit", :id => @user.id) do %>
<%= partial :form, :with => @user %>
<%= submit "Aktualizuj" %>
<% end =%>
1 change: 1 addition & 0 deletions app/views/users/index.html.erb
@@ -0,0 +1 @@
<%= tabular(*@users) %>
10 changes: 10 additions & 0 deletions config/dependencies.rb
Expand Up @@ -11,3 +11,13 @@
end
dependency "merb-helpers", merb_gems_version
dependency "merb_cucumber"
dependency "merb-helpers", merb_gems_version
dependency "merb-mailer", merb_gems_version
dependency "merb-slices", merb_gems_version
dependency "merb-auth-core", merb_gems_version
dependency "merb-auth-more", merb_gems_version
dependency "merb-auth-slice-password", merb_gems_version
dependency "merb-param-protection", merb_gems_version
dependency "merb-exceptions", merb_gems_version


12 changes: 1 addition & 11 deletions config/router.rb
Expand Up @@ -27,17 +27,7 @@

Merb.logger.info("Compiling routes...")
Merb::Router.prepare do
# RESTful routes
# resources :posts

# Adds the required routes for merb-auth using the password slice

# This is the default route for /:controller/:action/:id
# This is fine for most cases. If you're heavily using resource-based
# routes, you may want to comment/remove this line to prevent
# clients from calling your create or destroy actions with a GET
add_slice(:MerbAuthSlicePassword, :path_prefix => "")
default_routes

# Change this for your home page to be available at /
match('/').to(:controller => 'dashboard', :action =>'index')
end
45 changes: 45 additions & 0 deletions merb/merb-auth/setup.rb
@@ -0,0 +1,45 @@
# This file is specifically setup for use with the merb-auth plugin.
# This file should be used to setup and configure your authentication stack.
# It is not required and may safely be deleted.
#
# To change the parameter names for the password or login field you may set either of these two options
#
#Merb::Plugins.config[:"merb-auth"][:login_param] = :email
#Merb::Plugins.config[:"merb-auth"][:password_param] = :my_password_field_name

begin
# Sets the default class ofr authentication. This is primarily used for
# Plugins and the default strategies
Merb::Authentication.user_class = User


# Mixin the salted user mixin
require 'merb-auth-more/mixins/salted_user'
Merb::Authentication.user_class.class_eval{ include Merb::Authentication::Mixins::SaltedUser }

# Setup the session serialization
class Merb::Authentication

def fetch_user(session_user_id)
Merb::Authentication.user_class.get(session_user_id)
end

def store_user(user)
user.nil? ? user : user.id
end
end

rescue Exception => e
puts e.message
Merb.logger.error <<-TEXT
You need to setup some kind of user class with merb-auth.
Merb::Authentication.user_class = User
If you want to fully customize your authentication you should use merb-core directly.
See merb/merb-auth/setup.rb and strategies.rb to customize your setup
TEXT
end

11 changes: 11 additions & 0 deletions merb/merb-auth/strategies.rb
@@ -0,0 +1,11 @@
# This file is specifically for you to define your strategies
#
# You should declare you strategies directly and/or use
# Merb::Authentication.activate!(:label_of_strategy)
#
# To load and set the order of strategy processing

Merb::Slices::config[:"merb-auth-slice-password"][:no_default_strategies] = true

Merb::Authentication.activate!(:default_password_form)
Merb::Authentication.activate!(:default_basic_auth)
9 changes: 9 additions & 0 deletions merb/session/session.rb
@@ -0,0 +1,9 @@
module Merb
module Session

# The Merb::Session module gets mixed into Merb::SessionContainer to allow
# app-level functionality; it will be included and methods will be available
# through request.session as instance methods.

end
end
18 changes: 18 additions & 0 deletions schema/migrations/006_user_migration.rb
@@ -0,0 +1,18 @@
# For details on Sequel migrations see:
# * http://sequel.rubyforge.org/
# * http://sequel.rubyforge.org/rdoc-plugins/classes/Sequel/Migration.html

class UserMigration < Sequel::Migration
def up
create_table :users do
primary_key :id
varchar :login, :null => false
varchar :crypted_password
varchar :salt
end
end

def down
drop_table :users
end
end

0 comments on commit 9475800

Please sign in to comment.