Skip to content

Commit 982627f

Browse files
committed
improvement: cron interface
1 parent 99be482 commit 982627f

File tree

5 files changed

+22
-19
lines changed

5 files changed

+22
-19
lines changed

static/websiteFunctions/websiteFunctions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,6 +2830,8 @@ app.controller('manageCronController', function ($scope, $http) {
28302830
$("#cronEditSuccess").hide();
28312831
$("#fetchCronFailure").hide();
28322832

2833+
$scope.websiteToBeModified = $("#domain").text();
2834+
28332835
$scope.fetchWebsites = function () {
28342836

28352837
$("#manageCronLoading").show();
@@ -2880,6 +2882,7 @@ app.controller('manageCronController', function ($scope, $http) {
28802882
$("#cronEditSuccess").hide();
28812883
}
28822884
};
2885+
$scope.fetchWebsites();
28832886

28842887
$scope.fetchCron = function (cronLine) {
28852888

@@ -3033,7 +3036,6 @@ app.controller('manageCronController', function ($scope, $http) {
30333036
}
30343037
};
30353038

3036-
30373039
$scope.removeCron = function (line) {
30383040

30393041
$("#manageCronLoading").show();

websiteFunctions/static/websiteFunctions/websiteFunctions.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2830,6 +2830,8 @@ app.controller('manageCronController', function ($scope, $http) {
28302830
$("#cronEditSuccess").hide();
28312831
$("#fetchCronFailure").hide();
28322832

2833+
$scope.websiteToBeModified = $("#domain").text();
2834+
28332835
$scope.fetchWebsites = function () {
28342836

28352837
$("#manageCronLoading").show();
@@ -2880,6 +2882,7 @@ app.controller('manageCronController', function ($scope, $http) {
28802882
$("#cronEditSuccess").hide();
28812883
}
28822884
};
2885+
$scope.fetchWebsites();
28832886

28842887
$scope.fetchCron = function (cronLine) {
28852888

@@ -3033,7 +3036,6 @@ app.controller('manageCronController', function ($scope, $http) {
30333036
}
30343037
};
30353038

3036-
30373039
$scope.removeCron = function (line) {
30383040

30393041
$("#manageCronLoading").show();

websiteFunctions/templates/websiteFunctions/listCron.html

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,19 @@ <h2 style="display: inline;">{% trans "Cron Management" %} - <a target="_blank"
1616
<div class="panel">
1717
<div class="panel-body">
1818
<h3 class="title-hero">
19-
{% trans "Cron Management" %} <img id="manageCronLoading" src="{% static 'images/loading.gif' %}">
19+
{% trans "Cron Management" %} - <span id="domain">{{ domain }}</span> <img id="manageCronLoading" src="{% static 'images/loading.gif' %}">
2020
</h3>
2121
<div class="example-box-wrapper">
2222

2323

2424
<form action="/" class="form-horizontal bordered-row">
2525

26-
27-
<div class="form-group">
28-
<label class="col-sm-3 control-label">{% trans "Select Website" %} </label>
29-
<div class="col-sm-6">
30-
<select ng-change="fetchWebsites()" ng-model="websiteToBeModified" class="form-control">
31-
{% for items in websiteList %}
32-
<option>{{ items }}</option>
33-
{% endfor %}
34-
</select>
35-
</div>
36-
<button type="button" class="btn btn-primary" ng-click="fetchWebsites()" href=""><i class="glyph-icon icon-refresh" title="{% trans "Refresh" %}"></i></button>
37-
<button type="button" class="btn btn-primary" ng-click="addCronForm()" href=""><i class="glyph-icon icon-plus" title="{% trans "Add Cron" %}"></i></button>
26+
<div style="padding-bottom: 0px; margin-bottom: 0px" class="form-group">
27+
<a style="margin-left: 1%" ng-click="addCronForm()" class="btn btn-border btn-alt border-blue btn-link font-blue" href="#" title=""><span>{% trans "Add Cron" %}</span></a>
28+
<a ng-click="fetchWebsites()" class="btn btn-border btn-alt border-blue btn-link font-blue" href="#" title=""><span>{% trans "Fetch Current Cron Jobs" %}</span></a>
3829
</div>
3930

31+
<hr>
4032

4133
<!------ Modification form that appears after a click --------------->
4234

@@ -74,7 +66,6 @@ <h3 class="title-hero">
7466
<div id="modifyCronForm">
7567
<form action="/" class="form-horizontal bordered-row ng-scope ng-dirty ng-valid-parse ng-valid ng-valid-required">
7668
<input type="hidden" ng-value="line" required="">
77-
<hr>
7869
<div class="form-group">
7970
<label class="col-sm-3 control-label">{% trans "Pre defined" %}</label>
8071
<div class="col-sm-6">

websiteFunctions/templates/websiteFunctions/website.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ <h3 class="content-box-header">
272272
</div>
273273

274274
<div class="col-md-3 panel-body">
275-
<a href="{% url 'listCron' %}" target="_blank" title="{% trans 'Add new Cron Job' %}"
275+
<a href="{% url 'listCron' %}?domain={{ domain }}" target="_blank" title="{% trans 'Add new Cron Job' %}"
276276
href="" title="{% trans 'List Domains' %}">
277277
<img src="{% static 'images/icons/repeat.png' %}" width="65" class="mr-10">
278278
</a>
279-
<a href="{% url 'listCron' %}" target="_blank" title="{% trans 'List Domains' %}"
279+
<a href="{% url 'listCron' %}?domain={{ domain }}" target="_blank" title="{% trans 'Add new Cron Job' %}"
280280
title="{% trans 'Add new Cron Job' %}">
281281
<span class="h4">{% trans "Cron Jobs" %}</span>
282282
</a>

websiteFunctions/website.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,17 @@ def listChildDomains(self, request=None, userID=None, data=None):
131131

132132
def listCron(self, request=None, userID=None, data=None):
133133
try:
134+
134135
currentACL = ACLManager.loadedACL(userID)
136+
admin = Administrator.objects.get(pk=userID)
137+
138+
if ACLManager.checkOwnership(request.GET.get('domain'), admin, currentACL) == 1:
139+
pass
140+
else:
141+
return ACLManager.loadError()
142+
135143
websitesName = ACLManager.findAllSites(currentACL, userID)
136-
return render(request, 'websiteFunctions/listCron.html', {'websiteList': websitesName})
144+
return render(request, 'websiteFunctions/listCron.html', {'domain': request.GET.get('domain'), 'websiteList': websitesName})
137145
except BaseException as msg:
138146
return HttpResponse(str(msg))
139147

0 commit comments

Comments
 (0)