-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add missing files for system config functionality
- Loading branch information
Showing
30 changed files
with
5,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
=pod | ||
Brass | ||
Copyright (C) 2024 Ctrl O Ltd | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License as | ||
published by the Free Software Foundation, either version 3 of the | ||
License, or (at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Affero General Public License for more details. | ||
You should have received a copy of the GNU Affero General Public License | ||
along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
=cut | ||
|
||
package Brass::DBIC; | ||
|
||
use base qw(DBIx::Class); | ||
|
||
# Used as a component for result sources to perform additional DBIC functions | ||
# (such as validation of values). For validation, the Result needs a | ||
# validate() function. It should raise an exception if there is a problem. | ||
|
||
sub insert | ||
{ my $self = shift; | ||
$self->_validate(@_); | ||
$self->_before_create(@_); | ||
my $guard = $self->result_source->schema->txn_scope_guard; | ||
my $return = $self->next::method(@_); | ||
$self->after_create | ||
if $self->can('after_create'); | ||
$guard->commit; | ||
$return; | ||
} | ||
|
||
sub delete | ||
{ my $self = shift; | ||
$self->before_delete | ||
if $self->can('before_delete'); | ||
$self->next::method(@_); | ||
} | ||
|
||
sub update | ||
{ my $self = shift; | ||
$self->_validate(@_); | ||
$self->next::method(@_); | ||
} | ||
|
||
sub _validate | ||
{ my ($self, $values) = @_; | ||
# If update() has been called with a set of values, then these need to be | ||
# updated in the object first, otherwise validation will be done on the | ||
# existing values in the object not the new ones. | ||
if ($values) | ||
{ | ||
$self->$_($values->{$_}) foreach keys %$values; | ||
} | ||
$self->validate | ||
if $self->can('validate'); | ||
}; | ||
|
||
sub _before_create | ||
{ my $self = shift; | ||
$self->before_create | ||
if $self->can('before_create'); | ||
}; | ||
|
||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use utf8; | ||
package Brass::Schema::Result::Config; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Log::Report; | ||
use Net::CIDR; | ||
|
||
use base 'DBIx::Class::Core'; | ||
|
||
__PACKAGE__->load_components("+Brass::DBIC"); | ||
|
||
__PACKAGE__->table("config"); | ||
|
||
__PACKAGE__->add_columns( | ||
"id", | ||
{ data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, | ||
"internal_networks", | ||
{ data_type => "text", is_nullable => 1 }, | ||
"smtp_relayhost", | ||
{ data_type => "text", is_nullable => 1 }, | ||
); | ||
|
||
__PACKAGE__->set_primary_key("id"); | ||
|
||
sub validate | ||
{ my $self = shift; | ||
|
||
foreach my $range (split /[\s,]+/, $self->internal_networks) | ||
{ | ||
Net::CIDR::cidrvalidate($range) | ||
or error __x"Invalid IP range restriction: {range}", range => $range; | ||
} | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
{ | ||
"belongs_to" : { | ||
"fetch" : 0 | ||
}, | ||
"sets" : [ | ||
{ | ||
"quantity" : "all", | ||
"class" : "Config" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "ServerServertype" | ||
}, | ||
{ | ||
"class" : "IssueTag", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "CertLocationUse" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Domain" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Docsend" | ||
}, | ||
{ | ||
"class" : "App", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Docreadtype", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "DocDocreadtype" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "File" | ||
}, | ||
{ | ||
"class" : "Customer", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "User", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Tag", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "UserDocread" | ||
}, | ||
{ | ||
"class" : "Uad", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "ServerPw" | ||
}, | ||
{ | ||
"class" : "Project", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Cert" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "UserTopic" | ||
}, | ||
{ | ||
"class" : "EventPerson", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Permission", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Comment", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "CertUse" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Servertype" | ||
}, | ||
{ | ||
"class" : "UserProject", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "ServerCert", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Pw", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Event", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "PwServertype" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Site" | ||
}, | ||
{ | ||
"class" : "Issuetype", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "IssuePriority", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Status", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "Calendar", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Server" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "IssueStatus" | ||
}, | ||
{ | ||
"class" : "Eventtype", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "Issue" | ||
}, | ||
{ | ||
"quantity" : "all", | ||
"class" : "UserDocreadtype" | ||
}, | ||
{ | ||
"class" : "Priority", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "CertLocation", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "UserPermission", | ||
"quantity" : "all" | ||
}, | ||
{ | ||
"class" : "UserServertype", | ||
"quantity" : "all" | ||
} | ||
], | ||
"has_many" : { | ||
"fetch" : 0 | ||
}, | ||
"might_have" : { | ||
"fetch" : 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"has_many" : { | ||
"fetch" : 0 | ||
}, | ||
"sets" : [ | ||
{ | ||
"quantity" : "all", | ||
"class" : "Permission" | ||
} | ||
], | ||
"might_have" : { | ||
"fetch" : 0 | ||
}, | ||
"belongs_to" : { | ||
"fetch" : 0 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
$VAR1 = { | ||
'belongs_to' => { | ||
'fetch' => 0 | ||
}, | ||
'has_many' => { | ||
'fetch' => 0 | ||
}, | ||
'might_have' => { | ||
'fetch' => 0 | ||
}, | ||
'sets' => [ | ||
{ | ||
'quantity' => 'all', | ||
'class' => 'Permission' | ||
} | ||
] | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.001039 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can view documents', | ||
id => 1, | ||
name => 'doc' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can view configuration information', | ||
id => 10, | ||
name => 'config' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can write configuration information', | ||
id => 11, | ||
name => 'config_write' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can create and update any issue for certain projects', | ||
id => 12, | ||
name => 'issue_write_project' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can read the calendar', | ||
id => 13, | ||
name => 'calendar_read' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User can write to the calendar', | ||
id => 14, | ||
name => 'calendar_write' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User administrator', | ||
id => 15, | ||
name => 'user_admin' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User receives brass reports', | ||
id => 16, | ||
name => 'reports' | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
$HASH1 = { | ||
description | ||
=> 'User receives notification of all new issues', | ||
id => 17, | ||
name => 'new_issue_alert' | ||
}; |
Oops, something went wrong.