MT#6461 Let resellers rebrand their panel

Implement view for resellers to edit their css.
agranig/subprof
Andreas Granig 13 years ago
parent 4789f25e5b
commit f5ce7e9db5

@ -420,12 +420,25 @@ sub create_defaults :Path('create_defaults') :Args(0) :Does(ACL) :ACLDetachTo('/
return;
}
sub css :Chained('base') :PathPart('css') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
my ($self, $c) = @_;
$c->stash(template => 'reseller/branding.tt');
return;
}
sub edit_branding_css :Chained('base') :PathPart('css/edit') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
my ($self, $c) = @_;
$c->detach('/denied_page')
if($c->user->read_only);
$c->stash(template => 'reseller/details.tt');
my $back;
if($c->user->roles eq "admin") {
$c->stash(template => 'reseller/details.tt');
$back = $c->uri_for_action('/reseller/details', $c->req->captures);
} else {
$c->stash(template => 'reseller/branding.tt');
$back = $c->uri_for_action('/reseller/css', $c->req->captures);
}
my $reseller = $c->stash->{reseller}->first;
my $branding = $reseller->branding;
@ -447,7 +460,7 @@ sub edit_branding_css :Chained('base') :PathPart('css/edit') :Args(0) :Does(ACL)
c => $c,
form => $form,
fields => {},
back_uri => $c->uri_for('/reseller/details', $c->req->captures),
back_uri => $back,
);
if($posted && $form->validated) {
@ -485,13 +498,13 @@ sub edit_branding_css :Chained('base') :PathPart('css/edit') :Args(0) :Does(ACL)
desc => $c->loc('Failed to update reseller branding'),
);
}
NGCP::Panel::Utils::Navigation::back_or($c, $c->uri_for_action('/reseller/details', $c->req->captures));
NGCP::Panel::Utils::Navigation::back_or($c, $back);
}
$c->stash(close_target => $c->uri_for());
$c->stash(branding_form => $form);
$c->stash(branding_edit_flag => 1);
$c->stash(close_target => $c->uri_for_action('/reseller/details', $c->req->captures));
$c->stash(close_target => $back);
return;
}
@ -515,6 +528,12 @@ sub get_branding_logo :Chained('base') :PathPart('css/logo/download') :Args(0) {
sub delete_branding_logo :Chained('base') :PathPart('css/logo/delete') :Args(0) :Does(ACL) :ACLDetachTo('/denied_page') :AllowedRole(admin) :AllowedRole(reseller) {
my ($self, $c) = @_;
my $back;
if($c->user->roles eq "admin") {
$back = $c->uri_for_action('/reseller/details', $c->req->captures);
} else {
$back = $c->uri_for_action('/reseller/css', $c->req->captures);
}
my $reseller = $c->stash->{reseller}->first;
my $branding = $reseller->branding;
@ -523,7 +542,7 @@ sub delete_branding_logo :Chained('base') :PathPart('css/logo/delete') :Args(0)
$branding->update({ logo => undef, logo_image_type => undef });
}
$c->response->redirect($c->uri_for_action('/reseller/details', $c->req->captures));
$c->response->redirect($back);
}
sub get_branding_css :Chained('base') :PathPart('css/download') :Args(0) {

@ -0,0 +1,75 @@
[% site_config.title = c.loc('Panel Branding') -%]
<div class="row">
<span>
<a class="btn btn-primary btn-large" href="[% c.uri_for('/back') %]"><i class="icon-arrow-left"></i> [% c.loc('Back') %]</a>
</span>
</div>
[% back_created = 1 -%]
<div class="ngcp-separator"></div>
<div class="row">
[% FOREACH m IN messages -%]
<div class="alert alert-[% m.type %]">[% m.text %]</div>
[% END -%]
[% IF reseller.first.status != "active" -%]
<div class="alert">[% c.loc('Reseller is <b>[_1]</b>', reseller.first.status) %]</div>
[% END -%]
[% messages = [] -%]
</div>
[% UNLESS c.user.read_only -%]
<span>
<a href="[% c.uri_for_action('/reseller/edit_branding_css', c.req.captures) %]" class="btn btn-large btn-primary"><i class="icon-edit"></i> Edit Branding</a>
[% IF branding.logo -%]
<a href="[% c.uri_for_action('/reseller/delete_branding_logo', c.req.captures) %]" class="btn btn-large btn-primary"><i class="icon-trash"></i> Delete Logo</a>
[% END -%]
</span>
<div class="ngcp-separator"></div>
[% END -%]
[% IF branding.defined -%]
[% IF branding.logo.defined -%]
<h3>Custom Logo</h3>
<img src="[% c.uri_for_action('/reseller/get_branding_logo', c.req.captures) %]">
<p>
[% c.loc("You can use the logo by adding the following CSS to the Custom CSS below:") %]
<pre>
#header .brand {
background: url([% c.uri_for_action('/reseller/get_branding_logo', c.req.captures) %]) no-repeat 0 0;
background-size: 280px 32px;
}
</pre>
</p>
[% ELSE -%]
No logo uploaded.
[% END -%]
<h3>Custom CSS</h3>
<p>
<pre style="color:#000">
[% branding.css %]
</pre>
</p>
[% ELSE -%]
No branding specified, using standard branding.
[% END -%]
[% IF branding_edit_flag == 1 -%]
[%
IF form.has_for_js;
form.render_repeatable_js;
END;
PROCESS "helpers/modal.tt";
modal_header(m.edit_flag = branding_edit_flag,
m.name = "Reseller Branding");
translate_form(branding_form).render;
modal_footer();
modal_script(m.close_target = close_target);
-%]
[% END -%]
[% # vim: set tabstop=4 syntax=html expandtab: -%]

@ -265,6 +265,7 @@
No branding specified, using standard branding.
[% END -%]
</div>
</div>
</div>

@ -5,6 +5,7 @@
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="[% c.uri_for_action('/reseller/css', [c.user.reseller_id]) %]">[% c.loc('Panel Branding') %]</a></li>
<li><a href="[% c.uri_for('/administrator') %]">[% c.loc('Administrators') %]</a></li>
<li><a href="[% c.uri_for('/customer') %]">[% c.loc('Customers') %]</a></li>
<li><a href="[% c.uri_for('/contact') %]">[% c.loc('Contacts') %]</a></li>

Loading…
Cancel
Save