Skip to content

Commit

Permalink
Stable Release Part 1.0.0 (#221)
Browse files Browse the repository at this point in the history
* Adjust request & response logs.

* Different way for exception handling.

* Replace app.modules.core.response.Response with app.controllers.controller.Controller

* Adjust api.private.v1.* to use app.controllers.controller.Controller

* Add log filter.

* Move app.modules.core.Request functionality to app.controllers.controller.Controller

* Move app.modules.core.Context functionality to app.controllers.controller.Controller

* Add Request Id to all logs.
  • Loading branch information
Clivern authored May 25, 2020
1 parent 2bd06e9 commit 7b9e975
Show file tree
Hide file tree
Showing 74 changed files with 1,399 additions and 1,856 deletions.
2 changes: 1 addition & 1 deletion .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DJANGO_LOGGING_LEVEL=warning
DJANGO_LOGGING_PROPAGATE=false

APP_LOGGING_HANDLERS=file
APP_LOGGING_LEVEL=warning
APP_LOGGING_LEVEL=info
APP_LOGGING_PROPAGATE=true

ACTIVATE_NOTIFICATIONS=false
Expand Down
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ DJANGO_LOGGING_LEVEL=warning
DJANGO_LOGGING_PROPAGATE=false

APP_LOGGING_HANDLERS=file
APP_LOGGING_LEVEL=warning
APP_LOGGING_LEVEL=info
APP_LOGGING_PROPAGATE=true

ACTIVATE_NOTIFICATIONS=false
Expand Down
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ before_script:
# command to run tests
script:
- make ci
- cat storage/logs/*.log

# Push the results back to coveralls
after_success:
Expand Down
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
<p align="center">A Status and Incident Communication Tool.</p>
<p align="center">
<a href="https://travis-ci.org/silverbackhq/Silverback"><img src="https://travis-ci.org/silverbackhq/Silverback.svg?branch=master"></a>
<a href='https://coveralls.io/github/silverbackhq/silverback?branch=master'><img src='https://coveralls.io/repos/github/silverbackhq/silverback/badge.svg?branch=master' alt='Coverage Status' /></a>
<a href="https://hub.docker.com/r/clivern/silverback"><img src="https://img.shields.io/badge/Docker-Latest-orange"></a>
<a href="https://sonarcloud.io/dashboard?id=silverbackhq_silverback"><img src="https://sonarcloud.io/api/project_badges/measure?project=silverbackhq_silverback&metric=alert_status"></a>
<a href='https://coveralls.io/github/silverbackhq/silverback?branch=master'><img src='https://coveralls.io/repos/github/silverbackhq/silverback/badge.svg?branch=master' alt='Coverage Status' /></a>
<a href="https://hub.docker.com/r/clivern/silverback"><img src="https://img.shields.io/badge/Docker-Latest-orange"></a>
<a href="https://github.com/silverbackhq/Silverback/releases"><img src="https://img.shields.io/badge/Version-v1.0.0--alpha.1-blue.svg"></a>
<a href="https://github.com/silverbackhq/Silverback/blob/master/LICENSE"><img src="https://img.shields.io/badge/LICENSE-Apache--2.0-orange.svg"></a>
</p>
</p>
<p align="center">
<a href="https://heroku.com/deploy" target="_blank"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy"></a>
<a href="https://heroku.com/deploy" target="_blank"><img src="https://www.herokucdn.com/deploy/button.svg" alt="Deploy"></a>
</p>


Expand Down
1 change: 0 additions & 1 deletion app/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@

from .celery import app as celery_app


__all__ = (celery_app)
25 changes: 5 additions & 20 deletions app/controllers/api/private/v1/admin/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,25 @@

# Third Party Library
from django.views import View
from pyvalitron.form import Form
from django.http import JsonResponse

# Local Library
from app.modules.util.helpers import Helpers
from app.modules.core.request import Request
from app.modules.core.response import Response
from app.modules.validation.extension import ExtraRules
from app.controllers.controller import Controller
from app.modules.core.decorators import allow_if_authenticated
from app.modules.core.activity import Activity as ActivityModule


class Activities(View):
class Activities(View, Controller):
"""List Activities Private Endpoint Controller"""

def __init__(self):
self.__request = Request()
self.__response = Response()
self.__helpers = Helpers()
self.__form = Form()
self.__activity = ActivityModule()
self.__logger = self.__helpers.get_logger(__name__)
self.__user_id = None
self.__correlation_id = ""
self.__form.add_validator(ExtraRules())

@allow_if_authenticated
def get(self, request):

self.__correlation_id = request.META["X-Correlation-ID"] if "X-Correlation-ID" in request.META else ""
self.__user_id = request.user.id
self.__request.set_request(request)

request_data = self.__request.get_request_data("get", {
request_data = self.get_request_data(request, "get", {
"offset": 0,
"limit": 20
})
Expand All @@ -59,14 +44,14 @@ def get(self, request):
offset = 0
limit = 20

return JsonResponse(self.__response.send_private_success([], {
return self.json([], {
'activities': self.__format_activities(self.__activity.get(self.__user_id, offset, limit)),
'metadata': {
'offset': offset,
'limit': limit,
'count': self.__activity.count(self.__user_id)
}
}, self.__correlation_id))
})

def __format_activities(self, activities):
activities_list = []
Expand Down
Loading

0 comments on commit 7b9e975

Please sign in to comment.