[Rt-commit] r5988 - in commitbit: . trunk/lib/CommitBit/Model
trunk/share/web/templates
jesse at bestpractical.com
jesse at bestpractical.com
Tue Sep 19 06:08:44 EDT 2006
Author: jesse
Date: Tue Sep 19 06:08:40 2006
New Revision: 5988
Added:
commitbit/trunk/share/web/templates/prefs
Modified:
commitbit/ (props changed)
commitbit/trunk/lib/CommitBit/Dispatcher.pm
commitbit/trunk/lib/CommitBit/Model/User.pm
Log:
r27665 at pinglin: jesse | 2006-09-19 10:38:44 +0200
* preferences!
Modified: commitbit/trunk/lib/CommitBit/Dispatcher.pm
==============================================================================
--- commitbit/trunk/lib/CommitBit/Dispatcher.pm (original)
+++ commitbit/trunk/lib/CommitBit/Dispatcher.pm Tue Sep 19 06:08:40 2006
@@ -11,6 +11,7 @@
};
before '*' => run {
if (Jifty->web->current_user->id) {
+ Jifty->web->navigation->child( prefs=>label=>_( 'Preferences'), url => '/prefs', sort_order => 998);
Jifty->web->navigation->child( logout=>label=>_( 'Logout'), url => '/logout', sort_order => 999);
} else {
Jifty->web->navigation->child(login=>label=>_( 'Login'), url => '/login', sort_order => 999);
@@ -21,7 +22,7 @@
};
-before '/admin/' => run {
+before qr'/admin/|/prefs' => run {
unless (Jifty->web->current_user->id) {
tangent '/login';
}
@@ -42,6 +43,20 @@
};
+on 'prefs' => run {
+ set 'action' =>
+ Jifty->web->new_action(
+ class => 'UpdateUser',
+ moniker => 'prefsbox',
+ record => Jifty->web->current_user->user_object
+ );
+
+ set 'next' => Jifty->web->request->continuation
+ || Jifty::Continuation->new(
+ request => Jifty::Request->new( path => "/" ) );
+
+};
+
# Login
on 'login' => run {
set 'action' =>
Modified: commitbit/trunk/lib/CommitBit/Model/User.pm
==============================================================================
--- commitbit/trunk/lib/CommitBit/Model/User.pm (original)
+++ commitbit/trunk/lib/CommitBit/Model/User.pm Tue Sep 19 06:08:40 2006
@@ -66,6 +66,15 @@
elsif (($right eq 'create' or $right eq 'update' or $right eq 'delete') and ($self->current_user->user_object && $self->current_user->user_object->admin)) {
return 1;
}
+
+ if ($right eq 'update' and ($self->current_user->user_object == $self->id)) {
+ if ($args{'column'} =~ /^(?:nickname|password)$/) {
+ return 1;
+ }
+
+
+ }
+
return $self->SUPER::current_user_can(@_);
}
1;
Added: commitbit/trunk/share/web/templates/prefs
==============================================================================
--- (empty file)
+++ commitbit/trunk/share/web/templates/prefs Tue Sep 19 06:08:40 2006
@@ -0,0 +1,14 @@
+<%args>
+$action
+$next
+</%args>
+<&|/_elements/wrapper, title => 'Preferences' &>
+<p>Update your password or nickname. (For now, you can't touch your email address)</p>
+<% Jifty->web->form->start(call => $next, name => "prefbox") %>
+<% $action->form_field('email', render_mode => 'read') %>
+<% $action->form_field('nickname') %>
+<% $action->form_field('password') %>
+<% $action->form_field('password_confirm') %>
+<% Jifty->web->form->submit(label => 'Save', submit => $action) %>
+<% Jifty->web->form->end %>
+</&>
More information about the Rt-commit
mailing list