Commit 5c360a84 authored by Roman Shishkin's avatar Roman Shishkin

Запрет публикации если один из сайтов запрещён

parent 762fba2e
......@@ -4,6 +4,7 @@ class Config:
DB_STRING = None
APP_ID = 0
APP_SECRET = 'fill_me'
GROUP_SECRET = 'c00adb77b7c2a87808177460546647f8636295e96fa5036cabac0570018ee28d8068792b457231298fe0f' # TODO(sparK) Move to private config!
GROUP_ID = 0
UPLOADS_DEFAULT_DEST = '../uploads'
UPLOADS_DEFAULT_URL = '/uploads/'
......
......@@ -96,6 +96,13 @@ def init(app):
choices = data.get('choices', None)
files = data.get('files', None)
if choices is not None:
for choice in choices:
domain = BlDomain.get(domain=choice['url'])
if domain is not None:
# Domain blacklisted
abort(403)
post = Post(
summary=data.get('summary'),
text=data.get('text', ''),
......
......@@ -4,7 +4,7 @@
<div class="panel-body">
<form class="form-horizontal" ng-submit="addItem()">
<div class="form-group wide-form">
<input type="text" ng-model="domain" class="form-control wide-form__input"
<input type="text" ng-model="domain" class="form-control wide-form__input" pattern="https?://.+"
placeholder="Домен сайта для внесения в чёрный список">
<button type="submit" class="btn btn-success wide-form__btn">
<span class="glyphicon glyphicon-plus"></span>
......
......@@ -34,14 +34,18 @@ class CreateController {
$scope.files = [];
$scope.choices = [];
$scope.flash_danger = false;
$scope.flash_text = 'Пост успешно отправлен!';
$scope.flash_info = true;
$scope.flash_type = 'info';
}, function errorCallback(response) {
$scope.flash_info = false;
$scope.flash_text = 'Произошла ошибка при отправке запроса';
$scope.flash_danger = true;
if (response.status === 403) {
$scope.flash_text = 'Один из указанных сайтов запрещён к публикации';
$scope.flash_type = 'danger';
} else {
$scope.flash_text = 'Произошла ошибка при отправке запроса';
$scope.flash_type = 'danger';
}
});
}
}
......
......@@ -3,8 +3,7 @@
<img class="header__image" src="/static/images/true_logo.png" alt="ЛЕНТАЧ">
<h1>Предложи нам новость!</h1>
</header>
<div class="alert alert-info" ng-show="flash_info">{{flash_text}}</div>
<div class="alert alert-danger" ng-show="flash_danger">{{flash_text}}</div>
<div class="alert alert-{{flash_type}}" ng-show="flash_type">{{flash_text}}</div>
<form ng-submit="send()">
<div class="input-group">
<label for="summary">
......@@ -18,7 +17,7 @@
Ссылки (не более 5): <a class="btn btn-xs btn-primary addfields" ng-click="addNewChoice()">Добавить поле</a>
</label>
<fieldset data-ng-repeat="choice in choices">
<input type="text" class="form-control" ng-model="choice.url" name="" pattern="https?://.+" placeholder="Введите адрес ссылки" style="width: 90%">
<input type="text" class="form-control" ng-model="choice.url" pattern="https?://.+" placeholder="Введите адрес ссылки" style="width: 90%">
<a class="btn btn-danger btn-small remove" ng-show="$last" ng-click="removeChoice()">-</a>
</fieldset>
</div>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment