From 78d6b4733f325995f16fbccfd58e110ce08e7bd4 Mon Sep 17 00:00:00 2001 From: Andy Beverley Date: Mon, 7 Oct 2024 14:47:41 +0100 Subject: [PATCH] Add system config functionality --- lib/Brass.pm | 25 +++++++++++++++++++++++++ lib/Brass/Schema.pm | 2 +- views/layouts/main.tt | 1 + 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/lib/Brass.pm b/lib/Brass.pm index e113359..41667bc 100644 --- a/lib/Brass.pm +++ b/lib/Brass.pm @@ -383,6 +383,31 @@ any ['get', 'post'] => '/config/server/?:id?' => require_role 'config' => sub { template 'config/server' => $params; }; +any ['get', 'post'] => '/config/site/' => require_role 'config' => sub { + + my $schema = schema; + + my $config = $schema->resultset('Config')->next + || $schema->resultset('Config')->new({}); + + if (body_parameters->get('save')) + { + error __"No permission to update config" + unless user_has_role 'config_write'; + $config->smtp_relayhost(body_parameters->get('smtp_relayhost')); + $config->internal_networks(body_parameters->get('internal_networks')); + if (process sub { $config->insert_or_update }) + { + forwardHome({ success => "The configuration has been updated successfully" }, "config/site/" ); + } + } + + template 'config/site' => { + config => $config, + page => 'config/site', + }; +}; + any ['get', 'post'] => '/config/uad/?:id?' => require_role 'config' => sub { my $id = param 'id'; diff --git a/lib/Brass/Schema.pm b/lib/Brass/Schema.pm index d85ef25..92424b2 100644 --- a/lib/Brass/Schema.pm +++ b/lib/Brass/Schema.pm @@ -15,7 +15,7 @@ __PACKAGE__->load_namespaces; # Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-10-01 11:03:29 # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GqW9kl7MrcAx0vieFGh+cw -our $VERSION = 42; +our $VERSION = 43; # You can replace this text with custom code or comments, and it will be preserved on regeneration 1; diff --git a/views/layouts/main.tt b/views/layouts/main.tt index 2f9bd99..4c5614a 100644 --- a/views/layouts/main.tt +++ b/views/layouts/main.tt @@ -65,6 +65,7 @@ Config