<commit_before>use strict;
use warnings;

package Qublog::Model::User;
use Jifty::DBI::Schema;

use DateTime::TimeZone;

=head1 NAME

Qublog::Model::User - a user account

=head1 SYNOPSIS

  # Please add one

=head1 DESCRIPTION

As of Qublog schema version 0.5.0 a single user object is associated with the database.

=head1 SCHEMA

=head2 name

This is the name of the user.

=head2 email

This is the email address of the user. This isn't used for anything yet.

=head2 email_verified

A boolean value telling whether we are pretty sure the email address belongs to
this user or not.

=head2 password

<PASSWORD>.

=head2 time_zone

This is the time zone of the user. It must be a scalar name provided by
L<DateTime::TimeZone>.

=cut

use Qublog::Record schema {
    column name =>
        type is 'text',
        label is 'Name',
        is mandatory,
        is distinct,
        ;

    column email =>
        type is 'text',
        label is 'Email',
        ;

    column email_verified =>
        type is 'bool',
        label is 'Email Verified?',
        is mandatory,
        default is 0,
        ;

    column password =>
        type is 'text',
        label is 'Password',
        render_as 'password',
        is mandatory,
        filters are qw/ Qublog::Filter::SaltHash /,
        ;

    column time_zone =>
        type is 'text',
        label is 'Time Zone',
        valid_values are defer {
            DateTime::TimeZone->all_names
        },
        since '0.5.2',
        is mandatory,
        default is 'US/Central',
        ;
};

=head1 METHODS

=head2 since

This class was added in schema version 0.5.0.

=cut

sub since { '0.5.0' }

=head2 current_user_can

The user can. Everyone else can't.

=cut

sub current_user_can {
    my $self = shift;
    my ($op, $args) = @_;
    return 1 if $op eq 'create';
    return 1 if $self->current_user->owns($self);
    return $self->SUPER::current_user_can(@_);
}

=head1 AUTHOR

<NAME> C<< <<EMAIL>> >>

=head1 COPYRIGHT AND LICENSE

Copyright 2008 <NAME>.

=cut<commit_msg>Fixing ownership of users<commit_after>use strict;
use warnings;

package Qublog::Model::User;
use Jifty::DBI::Schema;

use DateTime::TimeZone;

=head1 NAME

Qublog::Model::User - a user account

=head1 SYNOPSIS

  # Please add one

=head1 DESCRIPTION

As of Qublog schema version 0.5.0 a single user object is associated with the database.

=head1 SCHEMA

=head2 name

This is the name of the user.

=head2 email

This is the email address of the user. This isn't used for anything yet.

=head2 email_verified

A boolean value telling whether we are pretty sure the email address belongs to
this user or not.

=head2 password

<PASSWORD>.

=head2 time_zone

This is the time zone of the user. It must be a scalar name provided by
L<DateTime::TimeZone>.

=cut

use Qublog::Record schema {
    column name =>
        type is 'text',
        label is 'Name',
        is mandatory,
        is distinct,
        ;

    column email =>
        type is 'text',
        label is 'Email',
        ;

    column email_verified =>
        type is 'bool',
        label is 'Email Verified?',
        is mandatory,
        default is 0,
        ;

    column password =>
        type is 'text',
        label is 'Password',
        render_as 'password',
        is mandatory,
        filters are qw/ Qublog::Filter::SaltHash /,
        ;

    column time_zone =>
        type is 'text',
        label is 'Time Zone',
        valid_values are defer {
            DateTime::TimeZone->all_names
        },
        since '0.5.2',
        is mandatory,
        default is 'US/Central',
        ;
};

=head1 METHODS

=head2 since

This class was added in schema version 0.5.0.

=cut

sub since { '0.5.0' }

=head2 owner

Returns self.

=cut

sub owner {
    my $self = shift;
    return $self;
}

=head2 current_user_can

The user can. Everyone else can't.

=cut

sub current_user_can {
    my $self = shift;
    my ($op, $args) = @_;
    return 1 if $op eq 'create';
    return 1 if $self->current_user->owns($self);
    return $self->SUPER::current_user_can(@_);
}

=head1 AUTHOR

<NAME> C<< <<EMAIL>> >>

=head1 COPYRIGHT AND LICENSE

Copyright 2008 <NAME>.

=cut
{'fraction_non_alphanumeric': 0.09871244635193133, 'fraction_numerical': 0.01597520267048164, 'mean_word_length': 2.4050324675324677, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 37, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1274088', 'n_tokens_mistral': 1391, 'n_tokens_neox': 1338, 'n_words': 492}