[Jifty-commit] r2465 - in jifty/branches/template-declare: . doc
lib lib/Jifty lib/Jifty/Plugin plugins/Login/lib/Jifty/Plugin
plugins/Login/lib/Jifty/Plugin/Login
plugins/Login/lib/Jifty/Plugin/Login/Action
plugins/Login/lib/Jifty/Plugin/Login/Model
plugins/Login/lib/Jifty/Plugin/Login/Notification
share/web/static/css
share/web/templates/__jifty/admin/fragments/list t/TestApp/t
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Fri Jan 5 00:38:50 EST 2007
Author: jesse
Date: Fri Jan 5 00:38:46 2007
New Revision: 2465
Added:
jifty/branches/template-declare/doc/declarative-test-design
jifty/branches/template-declare/doc/jifty-plugins-2.0
Removed:
jifty/branches/template-declare/plugins/Login/share/web/templates/logout
Modified:
jifty/branches/template-declare/ (props changed)
jifty/branches/template-declare/MANIFEST
jifty/branches/template-declare/Makefile.PL
jifty/branches/template-declare/lib/Jifty.pm
jifty/branches/template-declare/lib/Jifty/Action.pm
jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ConfirmEmail.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Login.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Logout.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Signup.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmAddress.pm
jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmLostPassword.pm
jifty/branches/template-declare/plugins/Login/share/web/templates/login
jifty/branches/template-declare/share/web/static/css/forms.css
jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/new_item
jifty/branches/template-declare/t/TestApp/t/06-validation.t
Log:
Mergedown from trunk
r46622 at pinglin (orig r2442): gugod | 2006-12-30 03:21:06 -0500
Remove an invalid extra </div>.
r46623 at pinglin (orig r2443): audreyt | 2006-12-30 13:18:14 -0500
* hlb++ reported that we really want HTTP::Server::Simple 0.26+,
not 0.20+, as 0.20 and 0.21's critical URI-path-processing
bug makes us non utf8 friendly.
r46754 at pinglin (orig r2453): kevinr | 2007-01-02 22:15:37 -0500
r30054 at sad-girl-in-snow: kevinr | 2007-01-02 19:36:53 -0600
* Added Data::UUID to the Makefile.PL and made sure we use'd it in Jifty.pm
r46755 at pinglin (orig r2454): jpeacock | 2007-01-03 12:31:57 -0500
r2107 at jfphome: jpeacock | 2007-01-02 20:37:12 -0500
Better handling of autocreated modules from plugins.
Print debug statements when autogenerating packages.
r46756 at pinglin (orig r2455): jpeacock | 2007-01-03 12:32:43 -0500
r2109 at jfphome: jpeacock | 2007-01-02 22:21:58 -0500
Almost complete reworking of the Login plugin.
r46757 at pinglin (orig r2456): jpeacock | 2007-01-03 12:33:21 -0500
r2110 at jfphome: jpeacock | 2007-01-03 10:50:08 -0500
Forgot this piece
r46758 at pinglin (orig r2457): jpeacock | 2007-01-03 12:33:34 -0500
r2111 at jfphome: jpeacock | 2007-01-03 11:10:41 -0500
It's funny how it is always the little things.
r46759 at pinglin (orig r2458): nelhage | 2007-01-04 17:51:19 -0500
Added notes from plugins design session
r46760 at pinglin (orig r2459): nelhage | 2007-01-04 18:05:37 -0500
Playing with syntax for a declarative test scheme
r46761 at pinglin (orig r2460): nelhage | 2007-01-04 18:55:20 -0500
Sketching what an identity plugin looks like
r46762 at pinglin (orig r2461): trs | 2007-01-05 00:30:29 -0500
r18665 at zot: tom | 2007-01-04 23:50:32 -0500
Only emit mandatory field warnings with Ajax when the field starts with data.
r46763 at pinglin (orig r2462): trs | 2007-01-05 00:30:39 -0500
r18666 at zot: tom | 2007-01-04 23:56:44 -0500
Indicate mandatory fields visually
r46764 at pinglin (orig r2463): trs | 2007-01-05 00:31:10 -0500
r18667 at zot: tom | 2007-01-05 00:29:11 -0500
TODO tests attempting to test if we get ajax validation errors for mandatory values after the sticky_value has been deleted
r46765 at pinglin (orig r2464): trs | 2007-01-05 00:33:13 -0500
r18673 at zot: tom | 2007-01-05 00:33:00 -0500
Less obstrusive mandatory visual indicator. This will likely almost always want app-specific styling.
Modified: jifty/branches/template-declare/MANIFEST
==============================================================================
--- jifty/branches/template-declare/MANIFEST (original)
+++ jifty/branches/template-declare/MANIFEST Fri Jan 5 00:38:46 2007
@@ -296,7 +296,6 @@
plugins/Login/share/web/templates/let/confirm_email
plugins/Login/share/web/templates/let/reset_lost_password
plugins/Login/share/web/templates/login
-plugins/Login/share/web/templates/logout
plugins/Login/share/web/templates/passwordreminder
plugins/Login/share/web/templates/signup
plugins/Nothing/lib/Jifty/Plugin/Nothing.pm
Modified: jifty/branches/template-declare/Makefile.PL
==============================================================================
--- jifty/branches/template-declare/Makefile.PL (original)
+++ jifty/branches/template-declare/Makefile.PL Fri Jan 5 00:38:46 2007
@@ -16,6 +16,7 @@
requires('CSS::Squish' => 0.05 );
requires('DBD::SQLite' => 1.11 );
requires('Data::Page');
+requires('Data::UUID');
requires('DateTime');
requires('Date::Manip');
requires('Email::Folder');
@@ -36,7 +37,7 @@
requires('HTML::Mason::Plugin');
requires('HTTP::Cookies');
requires('HTTP::Date');
-requires('HTTP::Server::Simple' => '0.20'); # HTTP::Server::Simple::CGI
+requires('HTTP::Server::Simple' => '0.26'); # HTTP::Server::Simple::CGI
requires('HTTP::Server::Simple::Recorder');
requires('Hash::Merge');
requires('Hook::LexWrap');
Added: jifty/branches/template-declare/doc/declarative-test-design
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/doc/declarative-test-design Fri Jan 5 00:38:46 2007
@@ -0,0 +1,105 @@
+# -*- mode: cperl -*-
+
+# A ``setup'' block indicates tests that must pass for any of the
+# remaining tests to continue.
+
+setup {
+ BTDT::Test->log_in;
+ expect_url(qr{/todo});
+ follow_link 'Groups';
+ expect_url(qr{/groups});
+ expect_content('alpha');
+
+ # These are custom local methods; not Test::WWW::Whatever ones.
+ make_and_verify_group($mech, name => 'my folks', desc => 'stuff');
+ make_and_verify_group($mech, name => 'blue pants', desc => 'some description');
+ make_and_verify_group_trimming($mech, name => ' leading and trailing spaces ', desc => ' more spaces here ');
+
+ make_and_verify_group($mech, name => 'other folks');
+}
+
+# Each ``test'' block is its own test. If anything fails, we abort the
+# current test block, and continue with the next one.
+
+test {
+ follow_link 'Groups';
+ follow_link 'New Group';
+ submit_action 'newgroup', { name => 'my folks' };
+
+ expect_url { not => qr{groups/\d+/members} };
+ expect_url qr{/groups/create};
+ find_input { value => "my folks" };
+ expect_content qr{Sorry, but someone else beat you to that name};
+};
+
+test {
+ follow_link 'my folks';
+ follow_link 'Members';
+
+ expect_url qr{/groups/\d+/members};
+ expect_content 'Manage group members';
+ expect_content 'my folks';
+ expect_content qr{Good Test *organizer}
+};
+
+test {
+ follow_link 'my folks';
+ follow_link 'My tasks';
+ follow_link 'Braindump';
+ expect_content 'See more syntax for braindump';
+
+ fill_action 'quickcreate', { text => 'Buy new computer [personal money]' };
+ click { button => 'Create' };
+
+ expect { content => 'Buy new computer' };
+ expect_content_not 'See more syntax for braindump';
+
+ follow_link 'my folks' => 'My tasks' => 'Braindump';
+ submit_action 'quickcreate',
+ { text => 'Buy new computer [personal money]' },
+ { button => 'Create' };
+
+ click 'Edit';
+
+ submit_action find_action('BTDT::Action::UpdateTask'),
+ { owner_id => 'otheruser at example.com' };
+}
+
+test {
+ new_session {
+ log_in 'otheruser at example.com', 'something';
+ click 'unaccepted';
+ page { content => 'Pay off Mafia' };
+ click 'Pay off Mafia';
+
+ # Manual submit_action
+ find_element { name => qr{J:A-(?:\d+)?accept} };
+ submit_form { 'J:A:F-accepted-accept' => 1 };
+
+ page { content => 'Task accepted',
+ content_lacks => 'denied' };
+
+ };
+};
+
+# Various ways of specifying tests should only run under certain
+# platforms
+
+with ('javascript') => test {
+
+};
+
+test {
+ browser 'iexplore';
+};
+
+test {
+ browser 'WWW::Mechanize';
+};
+
+test {
+ need_feature 'XMLHTTPRequest';
+};
+
+
+run_all;
Added: jifty/branches/template-declare/doc/jifty-plugins-2.0
==============================================================================
--- (empty file)
+++ jifty/branches/template-declare/doc/jifty-plugins-2.0 Fri Jan 5 00:38:46 2007
@@ -0,0 +1,141 @@
+* Plugins and actions need to work better
+* Plugins should be able to create model classes
+* So should applications
+* Plugins can add columns to model classes
+* Plugins can add logic to model classes (before_*, after_* hooks)
+* Plugins should be able to add properties to columns
+* The app always overrides plugins
+* Plugins are loaded and evaluated in order
+* Models should become mixins when appropriate
+ - But if the app doesn't define one, they can create classes/tables #'
+
+
+The plugins we want in our ponyverse:
+* ::Users
+* ::Users::Identity::EmailedToken
+* ::UsernamePassword
+* ::OpenID
+* ::Certs
+* ::{Assertion,Kerberos,...}
+* ::ResetIdentity (change password for any identity once logged in / add identity)
+* ::Users::Signup
+* ::Users::Login
+* ::Users::EmailAddress
+
+::Users
+* unique ID
+* created_date, update_date, created_by, updated_by
+* display_name field (which you can force to something -- e.g. email, openid, name from cert)
+ * (Jifty::Record _brief_description returns this?)
+* last_login (?)
+* Do superuser and nobody live in the database? (That's authz)
+
+Where do identity plugins hook?
+* Add columns
+* Get credentials, return:
+ * These are valid
+ * These are invalid
+ * Other auth error ``I don't know''
+ * bounce trips go through continuations
+* load_by_unique_id
+
+* ::Login
+* /login =>
+ * list of identity types
+ * for each, fields for login columns declared by the ::Identity::Foo plugin
+ * submit button
+* Login action
+ * load_by_unique_id
+ * if the user doesn't exist, callback (to signup) or error
+ * Passes credentials to the identity plugin's auth method
+ * Identities that need confirmation error here if needed
+ * frob the session as appropriate
+ * frob CurrentUser
+ * Adds Dispatcher variables
+* Logout action
+ * frob the session and current user
+ * dispatcher rule on /logout redirects
+
+* ::Signup
+* Signup action
+ * verifies credentials - validates fields (inc. uniqueness)
+ * Creates a record
+ * Add a message, and push the user to the login page with a filled-out login action
+
+* What do ``mixins'' *mean*?
+ * We want injection, not actual mixins
+
+
+----- Where is this going to be hard? -----
+* Mixing columns into users
+* Getting the autogenerated actions to DTRT
+* hooks look kinda like Plagger
+* If there are multiple plugin models with no app model,
+ they all get mixed into the null model
+
+
+----- Username/password plugin ------
+
+# Model (Jifty::Plugin::User::Identity::UsernamePassword::Model::User)
+
+column 'username' =>
+ type is 'text',
+ is unique;
+
+column 'password' =>
+ type is 'text',
+ render_as 'Password',
+ filters are qw(Jifty::DBI::Filter::SaltHash);
+
+sub password_is {
+ my $self = shift;
+ my $pass = shift;
+
+ return undef unless $self->_value('password');
+
+ my ($hash, $salt) = @{$self->_value('password')};
+
+ return 1 if ( $hash eq Digest::MD5::md5_hex($pass . $salt) );
+ return undef;
+
+}
+
+# ``exports''
+sub load_by_unique_id {
+ my $self = shift;
+ my %args = (username => undef, @_);
+ return $self->load_by_columns(username => $args{username});
+}
+
+sub validate_credentials {
+ my $self = shift;
+ my %args = (username => undef, @_);
+ return unless $self->id;
+ return $self->password_is($args{password});
+}
+
+# Jifty::Plugin::User::Identity::UsernamePassword::Action::Login
+
+param username =>
+ render_as 'Text';
+
+param password =>
+ render_as 'Password';
+
+
+
+# Login plugin Action::Login
+sub check_credentials {
+ my $self = shift;
+ my $userobj = MyApp::Model::User->new;
+ my $user;
+ foreach my $identity_type ($userobj->identity_plugins) {
+ if($userobj->($identity_type . "::load_by_unique_id")($self->argument_values)) {
+ if($userobj->($identity_type . "::validate_credentials")($self->argument_values)) {
+ ...
+ } else {
+ ...
+ }
+ }
+ }
+}
Modified: jifty/branches/template-declare/lib/Jifty.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty.pm (original)
+++ jifty/branches/template-declare/lib/Jifty.pm Fri Jan 5 00:38:46 2007
@@ -3,6 +3,7 @@
package Jifty;
use IPC::PubSub 0.22;
+use Data::UUID;
use encoding 'utf8';
# Work around the fact that Time::Local caches thing on first require
BEGIN { local $ENV{'TZ'} = "GMT"; require Time::Local;}
Modified: jifty/branches/template-declare/lib/Jifty/Action.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Action.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Action.pm Fri Jan 5 00:38:46 2007
@@ -854,11 +854,10 @@
my $value = $self->argument_value($field);
- if ( !defined $value || !length $value ) {
-
- if ( $field_info->{mandatory} ) {
- return $self->validation_error( $field => _("You need to fill in this field") );
- }
+ if ( $field_info->{mandatory}
+ and $self->_is_argument_value_deleted($field) )
+ {
+ return $self->validation_error( $field => _("You need to fill in this field") );
}
# If we have a set of allowed values, let's check that out.
@@ -895,6 +894,31 @@
}
}
+sub _is_argument_value_deleted {
+ my $self = shift;
+ my $field = shift;
+
+ my $value = $self->argument_value($field);
+
+ my $field_info = $self->arguments->{$field};
+ return unless $field_info;
+
+ my $default_value;
+ $default_value = $field_info->{'default_value'}
+ if exists $field_info->{'default_value'};
+ $default_value = $value
+ if $self->has_argument($field) && $value && !$self->values_from_request->{$field};
+
+ if ( not defined $value or not length $value ) {
+ if ( ( defined $default_value && $value ne $default_value )
+ || ( Jifty->web->request->path !~ m{^/__jifty/validator\.xml} ) )
+ {
+ return 1;
+ }
+ }
+ return 0;
+}
+
=head2 _autocomplete_argument ARGUMENT
Get back a list of possible completions for C<ARGUMENT>. The list
Modified: jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm
==============================================================================
--- jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm (original)
+++ jifty/branches/template-declare/lib/Jifty/Plugin/ClassLoader.pm Fri Jan 5 00:38:46 2007
@@ -116,32 +116,53 @@
# Note that at this point, all of the plugins classes will already be
# loaded, so we can just check their presence when deciding whether
# this is a class the plugin intends to autocreate
- if ( $module =~ m{^(?:$base)::(Notification|CurrentUser)$} ) {
- my $method = "${plugin}::$1";
- return Jifty::ClassLoader->return_class(
+ if ( $module =~ m{^(?:$base)::CurrentUser$} ) {
+ my $method = "${plugin}::CurrentUser";
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub _autogenerated { 1 };\n"
. "1;" )
- if Jifty::Util->already_required($method);
- }
- elsif ( $module =~ m{^(?:$base)::Action::([^\.]+)$} ) {
- my $method = $1;
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+ } elsif ( $module =~ m!^(?:$base)::Action::(Create|Update|Delete|Search)([^\.]+)$! ) {
+ my $model = "::Model::" . $2;
+ my $method = $plugin . "::Action::" . $1 . $2;
# Check to see if this is an action for a model that this plugin
# doesn't provide
- if ( $method =~ m/^(?:Create|Update|Delete)([^\.]+)$/ ) {
- my $model = "${plugin}::Model::$1";
- return undef unless Jifty::Util->already_required($model);
- }
+ return undef unless Jifty::Util->already_required("$plugin$model");
- $method = "${plugin}::Action::$method";
- return Jifty::ClassLoader->return_class(
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
+ "use warnings; use strict; package $module;\n"
+ . "use base qw/$method/;\n"
+ . "sub record_class { '$base$model' };\n"
+ . "sub autogenerated { 1 };\n"
+ . "1;" )
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+ } elsif ( $module =~ m{^(?:$base)::(Action|Notification)([^\.]+)$} ) {
+ my $method = $plugin . "::" . $1 . $2;
+ if ( Jifty::Util->already_required($method) ) {
+ Jifty->log->debug("Implementing $module using $method");
+ return Jifty::ClassLoader->return_class(
"use warnings; use strict; package $module;\n"
. "use base qw/$method/;\n"
. "sub autogenerated { 1 };\n"
. "1;" )
- if Jifty::Util->already_required($method);
+ }
+ else {
+ Jifty->log->debug("Couldn't implement $module using $method");
+ }
+
}
return undef;
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login.pm Fri Jan 5 00:38:46 2007
@@ -42,10 +42,9 @@
my $self = shift;
my %args = @_;
my $appname = Jifty->config->framework('ApplicationClass');
- $CurrentUserClass = $args{CurrentUserClass}
- || "${appname}::CurrentUser";
$LoginUserClass = $args{LoginUserClass}
- || "${appname}::Model::User";
+ || Jifty->app_class('Model','User');
+ $CurrentUserClass = Jifty->app_class('CurrentUser')
}
sub CurrentUserClass {
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ChangePassword.pm Fri Jan 5 00:38:46 2007
@@ -46,9 +46,9 @@
sub take_action {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
- my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
+ my $u = $LoginUserClass->new( current_user => $CurrentUser->superuser );
$u->load_by_cols( email => Jifty->web->current_user->user_object->email );
unless ($u) {
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ConfirmEmail.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ConfirmEmail.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ConfirmEmail.pm Fri Jan 5 00:38:46 2007
@@ -32,9 +32,9 @@
sub take_action {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
- my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
+ my $u = $LoginUserClass->new( current_user => $CurrentUser->superuser );
$u->load_by_cols( email => Jifty->web->current_user->user_object->email );
if ( $u->email_confirmed ) {
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Login.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Login.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Login.pm Fri Jan 5 00:38:46 2007
@@ -52,15 +52,15 @@
sub validate_email {
my $self = shift;
my $email = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
unless ( $email =~ /\S\@\S/ ) {
return $self->validation_error(
email => _("That doesn't look like an email address.") );
}
- my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $u = $LoginUserClass->new( current_user => $CurrentUser->superuser );
$u->load_by_cols( email => $email );
return $self->validation_error(
email => _('No account has that email address.') )
@@ -79,7 +79,7 @@
sub take_action {
my $self = shift;
- my $CurrentUser = $self->CurrentUserClass();
+ my $CurrentUser = Jifty->app_class('CurrentUser');
my $user = $CurrentUser->new( email => $self->argument_value('email') );
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Logout.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Logout.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Logout.pm Fri Jan 5 00:38:46 2007
@@ -29,6 +29,7 @@
sub take_action {
my $self = shift;
Jifty->web->current_user(undef);
+ $self->result->message( _("Ok, you're logged out now. Have a good day.") );
return 1;
}
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/ResetLostPassword.pm Fri Jan 5 00:38:46 2007
@@ -48,9 +48,9 @@
sub take_action {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
- my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
+ my $u = $LoginUserClass->new( current_user => $CurrentUser->superuser );
$u->load_by_cols( email => Jifty->web->current_user->user_object->email );
unless ($u) {
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendAccountConfirmation.pm Fri Jan 5 00:38:46 2007
@@ -44,11 +44,11 @@
sub setup {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
$self->user_object(
- $LoginUser->new( current_user => $CurrentUser->superuser ) );
+ $LoginUserClass->new( current_user => $CurrentUser->superuser ) );
}
=head2 validate_address
@@ -60,15 +60,15 @@
sub validate_address {
my $self = shift;
my $email = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
return $self->validation_error(
address => _("That doesn't look like an email address.") )
unless ( $email =~ /\S\@\S/ );
$self->user_object(
- $LoginUser->new( current_user => $CurrentUser->superuser ) );
+ $LoginUserClass->new( current_user => $CurrentUser->superuser ) );
$self->user_object->load_by_cols( email => $email );
return $self->validation_error(
address => _("It doesn't look like there's an account by that name.") )
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/SendPasswordReminder.pm Fri Jan 5 00:38:46 2007
@@ -47,12 +47,12 @@
sub setup {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
# Make a blank user object
$self->user_object(
- $LoginUser->new( current_user => $CurrentUser->superuser ) );
+ $LoginUserClass->new( current_user => $CurrentUser->superuser ) );
}
=head2 validate_address
@@ -64,15 +64,15 @@
sub validate_address {
my $self = shift;
my $email = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
return $self->validation_error(
address => _("That doesn't look like an email address.") )
unless ( $email =~ /\S\@\S/ );
$self->user_object(
- $LoginUser->new( current_user => $CurrentUser->superuser ) );
+ $LoginUserClass->new( current_user => $CurrentUser->superuser ) );
$self->user_object->load_by_cols( email => $email );
return $self->validation_error(
address => _("It doesn't look like there's an account by that name.") )
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Signup.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Signup.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Action/Signup.pm Fri Jan 5 00:38:46 2007
@@ -54,14 +54,14 @@
sub validate_email {
my $self = shift;
my $email = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
return $self->validation_error(
email => _("That doesn't look like an email address.") )
unless ( $email =~ /\S\@\S/ );
- my $u = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $u = $LoginUserClass->new( current_user => $CurrentUser->superuser );
$u->load_by_cols( email => $email );
if ( $u->id ) {
return $self->validation_error( email =>
@@ -84,9 +84,9 @@
sub take_action {
my $self = shift;
- my $LoginUser = $self->LoginUserClass();
- my $CurrentUser = $self->CurrentUserClass();
- my $record = $LoginUser->new( current_user => $CurrentUser->superuser );
+ my $LoginUserClass = $self->LoginUserClass;
+ my $CurrentUser = $self->CurrentUserClass;
+ my $record = $LoginUserClass->new( current_user => $CurrentUser->superuser );
my %values;
$values{$_} = $self->argument_value($_) for grep {
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Dispatcher.pm Fri Jan 5 00:38:46 2007
@@ -72,6 +72,10 @@
);
};
+on 'logout' => run {
+ redirect('/');
+};
+
## LetMes
before qr'^/let/(.*)' => run {
my $let_me = Jifty::LetMe->new();
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Model/User.pm Fri Jan 5 00:38:46 2007
@@ -29,17 +29,17 @@
render_as 'Unrendered';
package Jifty::Plugin::Login::Model::User;
-use base qw/Jifty::Record/;
-use Jifty::Plugin::Login::Notification::ConfirmAddress;
+use base qw/Jifty::Record Jifty::Plugin::Login/;
sub create {
my $self = shift;
my %args = (@_);
my (@ret) = $self->SUPER::create(%args);
+ my $confirmAddress = Jifty->app_class('Notification','ConfirmAddress');
+ Jifty::Util->require($confirmAddress);
if ( $self->id and not $self->email_confirmed ) {
- Jifty::Plugin::Login::Notification::ConfirmAddress->new( to => $self )
- ->send;
+ $confirmAddress->new( to => $self )->send;
}
return (@ret);
}
@@ -126,4 +126,16 @@
}
+=head2 record_class
+
+Identifies the correct record class for introspection
+
+=cut
+
+sub record_class {
+ my $self = shift;
+ return $self->LoginUserClass;
+
+}
+
1;
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmAddress.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmAddress.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmAddress.pm Fri Jan 5 00:38:46 2007
@@ -22,9 +22,8 @@
sub setup {
my $self = shift;
- my $LoginUser = $self->LoginUserClass;
- unless ( UNIVERSAL::isa($self->to, $LoginUser) ){
+ unless ( UNIVERSAL::isa($self->to, $self->LoginUserClass) ){
$self->log->error((ref $self) . " called with invalid user argument");
return;
}
Modified: jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmLostPassword.pm
==============================================================================
--- jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmLostPassword.pm (original)
+++ jifty/branches/template-declare/plugins/Login/lib/Jifty/Plugin/Login/Notification/ConfirmLostPassword.pm Fri Jan 5 00:38:46 2007
@@ -22,11 +22,10 @@
sub setup {
my $self = shift;
- my $LoginUser = $self->LoginUserClass;
- unless ( UNIVERSAL::isa($self->to, $LoginUser) ){
- $self->log->error((ref $self) . " called with invalid user argument");
- return;
+ unless ( UNIVERSAL::isa($self->to, $self->LoginUserClass) ){
+ $self->log->error((ref $self) . " called with invalid user argument");
+ return;
}
my $letme = Jifty::LetMe->new();
Modified: jifty/branches/template-declare/plugins/Login/share/web/templates/login
==============================================================================
--- jifty/branches/template-declare/plugins/Login/share/web/templates/login (original)
+++ jifty/branches/template-declare/plugins/Login/share/web/templates/login Fri Jan 5 00:38:46 2007
@@ -10,7 +10,9 @@
<% $action->form_field('email') %>
<% $action->form_field('password') %>
<% $action->form_field('remember') %>
-<% Jifty->web->form->submit(label => _('Login'), submit => $action) %>
+<div class="submit_button">
+<% Jifty->web->return(label => _('Login'), to => '/', submit => $action) %>
+</div>
<% Jifty->web->form->end %>
<% Jifty->web->tangent( label => _("Don't have an account?"), url => '/signup' )%>
% }
Modified: jifty/branches/template-declare/share/web/static/css/forms.css
==============================================================================
--- jifty/branches/template-declare/share/web/static/css/forms.css (original)
+++ jifty/branches/template-declare/share/web/static/css/forms.css Fri Jan 5 00:38:46 2007
@@ -205,3 +205,8 @@
input.placeholder, textarea.placeholder {
color: #666;
}
+
+form div.mandatory label {
+ font-weight: bold;
+}
+
Modified: jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/new_item
==============================================================================
--- jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/new_item (original)
+++ jifty/branches/template-declare/share/web/templates/__jifty/admin/fragments/list/new_item Fri Jan 5 00:38:46 2007
@@ -37,7 +37,7 @@
},
]
) %>
-</div>
+
<%doc>
When you hit "save" and create a item, you want to put a fragment
Modified: jifty/branches/template-declare/t/TestApp/t/06-validation.t
==============================================================================
--- jifty/branches/template-declare/t/TestApp/t/06-validation.t (original)
+++ jifty/branches/template-declare/t/TestApp/t/06-validation.t Fri Jan 5 00:38:46 2007
@@ -5,7 +5,7 @@
use lib 't/lib';
use Jifty::SubTest;
-use Jifty::Test tests => 14;
+use Jifty::Test tests => 22;
use Jifty::Test::WWW::Mechanize;
my $server = Jifty::Test->make_server;
@@ -42,3 +42,21 @@
" ... canonicalizer returned all lower case (good)");
$mech->content_contains('<canonicalization_note id="canonicalization_note-J:A:F-email-dosomething">Lowercased your email</canonicalization_note>',
" ... canonicalizer warned user");
+
+$mech->get_ok("$URL/dosomethingelse");
+$mech->fill_in_action_ok('dosomething',
+ 'foo' => 'something',
+ 'bar' => '',
+);
+$mech->submit_html_ok();
+$mech->content_contains('<span class="error text argument-bar" id="errors-J:A:F-bar-dosomething">You need to fill in this field</span>', 'got error for bar');
+$mech->content_contains('<span class="error text argument-foo" id="errors-J:A:F-foo-dosomething"></span>', 'got no error for foo');
+
+$mech->get_ok("$URL/__jifty/validator.xml?J:A-dosomething=TestApp::Action::DoSomethingElse&J:A:F-foo-dosomething=&J:A:F-bar-dosomething=blam&J:VALIDATE=1&_=",
+ "Getting validator.xml output for a form entry");
+$mech->content_lacks('<error id="errors-J:A:F-bar-dosomething">', " ... validator didn't return error for bar");
+
+TODO: {
+local $TODO = "Not implemented in Jifty yet";
+$mech->content_contains('<error id="errors-J:A:F-foo-dosomething">You need to fill in this field</error>', " ... validator returned error for foo");
+};
More information about the Jifty-commit
mailing list