Skip to content

Commit

Permalink
docs: update README file (#3)
Browse files Browse the repository at this point in the history
* Add the README file

* made changes to README

* added suggested changes

* docs: Move lines anitab-org#8 and anitab-org#10

* moved README outside .github

* remove extra README file

Fix pylint score

update requirements.txt for pylint

modified per review request and added travis tests

move travis
  • Loading branch information
menina763 authored and mtreacy002 committed Jun 6, 2020
1 parent c41978c commit 616bd93
Show file tree
Hide file tree
Showing 34 changed files with 775 additions and 350 deletions.
3 changes: 3 additions & 0 deletions .pylintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[MESSAGES CONTROL]
disable=missing-docstring, C0301, R0801, E203, E266, E501, W503, R0401, R0911, R0912, C0330, W0511, R0903, C0303, C0412, E0602, C0103, C0413, W0212, W0614, W0401, E1101, W0613, W0611, R0902, R0913, C0415
select = B,C,E,F,W,T4,B9,
25 changes: 25 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
language: python
sudo: required
python:
- '3.6'
cache: pip
services:
- postgresql
addons:
postgresql: '10'
apt:
packages:
- postgresql-10
- postgresql-client-10
env:
global:
- PGPORT=5432
before_script:
- psql -c 'create database bit_schema_test;' -U postgres
- psql -c 'create schema bitschema;' -U postgres
- psql -c 'create schema test_schema;' -U postgres
- psql -c 'create schema test_schema_2;' -U postgres
install:
- pip3 install -r requirements.txt
script:
- python -m unittest discover tests -v
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Bridge-In-Tech (backend)
Bridge-In-Tech is an application that allows industries/companies, mentors and students to actively collaborate to one another.

This is the backend client of Bridge-In-Tech.

## Contributing

**This project is under active development**



Please read our [Contributing Guidelines](.github/CONTRIBUTING.md), [Code of Conduct](.github/CODE_OF_CONDUCT.md) and [Reporting Guidelines](.github/REPORTING_GUIDELINES.md) thoroughly.


## Branches

This repository has the following branches:
- **master**: This branch contains the deployment of the backend.
- **develop**: This contains the latest code. All the contributing PRs must be sent to this branch.

## Contact

If you have any questions or want to discuss something about this repo, feel free to join our [Zulip Community](http://anitab-org.zulipchat.com/)! If you are a new contributor, head over to this project's stream [#bridge-in-tech](https://anitab-org.zulipchat.com/#narrow/stream/237630-bridge-in-tech) on Zulip to see ongoing discussions.

## License

The project is licensed under the GNU General Public License v3.0. Learn more about it in the [LICENSE](LICENSE) file.
2 changes: 0 additions & 2 deletions app/api/bit_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@
from app.api.resources.users import users_ns as user_namespace

api.add_namespace(user_namespace, path="/")


4 changes: 2 additions & 2 deletions app/api/dao/user_extension.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from http import HTTPStatus
from typing import Dict
from sqlalchemy import func
# from typing import Dict
# from sqlalchemy import func
from app.database.models.bit_schema.user_extension import UserExtensionModel
from app import messages

Expand Down
6 changes: 3 additions & 3 deletions app/api/jwt_extension.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from flask_jwt_extended import JWTManager
from http import HTTPStatus
from flask_jwt_extended import JWTManager
from app import messages
from app.api.bit_extension import api

Expand All @@ -15,10 +15,10 @@ def my_expired_token_callback():


@jwt.invalid_token_loader
def my_invalid_token_callback(error_message):
def my_invalid_token_callback():
return messages.TOKEN_IS_INVALID, HTTPStatus.UNAUTHORIZED


@jwt.unauthorized_loader
def my_unauthorized_request_callback(error_message):
def my_unauthorized_request_callback():
return messages.AUTHORISATION_TOKEN_IS_MISSING, HTTPStatus.UNAUTHORIZED
3 changes: 2 additions & 1 deletion app/api/models/user_extension.py → app/api/models/user.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from flask_restx import fields, Model
from app.utils.bitschema_utils import Timezone


def add_models_to_namespace(api_namespace):
api_namespace.models[register_user_api_model.name] = register_user_api_model


register_user_api_model = Model(
"User registration model",
{
Expand Down
40 changes: 10 additions & 30 deletions app/api/ms_api_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from flask import jsonify
import logging
import requests

# from requests.exceptions import HTTPError
from flask import json

from werkzeug.exceptions import HTTPException
import logging

# set base url

Expand All @@ -14,45 +14,25 @@
# for ms-api heroku server
# BASE_MS_API_URL = "https://bridge-in-tech-ms-test.herokuapp.com"

# @application.errorhandler(HTTPException)
# def handle_exception(e):
# """Return JSON instead of HTML for HTTP errors."""
# # start with the correct headers and status code from the error
# response = e.get_response()
# # replace the body with JSON
# response.data = json.dumps({
# "code": e.code,
# "name": e.name,
# "description": e.description,
# })
# response.content_type = "application/json"
# return response

# create instance
def post_request(request_url, data):
response = None,
response = (None,)
try:

response_raw = requests.post(
request_url,
json = data,
headers = {"Accept": "application/json"}
request_url, json=data, headers={"Accept": "application/json"}
)
response_raw.status_code = 201
response_raw.encoding = "utf-8"
response = response_raw.json()

except HTTPException as e:
response = e.get_response()
response.data = json.dumps({
"code": e.code,
"name": e.name,
"description": e.description,
})
response.data = json.dumps(
{"code": e.code, "name": e.name, "description": e.description,}
)
response.content_type = "application/json"

print(f"{response}")
logging.warning(f"{response}")
return response



32 changes: 18 additions & 14 deletions app/api/resources/users.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
from flask import request
from flask_restx import Resource, marshal, Namespace
from app.api.ms_api_utils import *
from app.api.dao.user_extension import UserExtensionDAO
from flask import json
from http import HTTPStatus
from flask import request
from flask_restx import Resource, Namespace
from app.api.ms_api_utils import post_request, BASE_MS_API_URL
# from app.api.dao.user_extension import UserExtensionDAO
from app import messages
from app.api.models.user_extension import *
from app.api.models.user import *

users_ns = Namespace("Users", description="Operations related to users")
add_models_to_namespace(users_ns)

DAO = UserExtensionDAO()
# DAO = UserExtensionDAO()


@users_ns.route("register")
class UserRegister(Resource):
@classmethod
@users_ns.doc("create_user")
@users_ns.response(HTTPStatus.CREATED, "%s" % messages.USER_WAS_CREATED_SUCCESSFULLY)
@users_ns.response(HTTPStatus.BAD_REQUEST, "%s" % messages.PASSWORD_INPUT_BY_USER_HAS_INVALID_LENGTH)
@users_ns.response(
HTTPStatus.CREATED, "%s" % messages.USER_WAS_CREATED_SUCCESSFULLY
)
@users_ns.response(
HTTPStatus.BAD_REQUEST,
"%s" % messages.PASSWORD_INPUT_BY_USER_HAS_INVALID_LENGTH,
)
@users_ns.response(
HTTPStatus.CONFLICT,
"%s\n%s\n%s"
"%s\n%s"
% (
messages.USER_USES_A_USERNAME_THAT_ALREADY_EXISTS,
messages.USER_USES_AN_EMAIL_ID_THAT_ALREADY_EXISTS,
),
)
@users_ns.response(HTTPStatus.INTERNAL_SERVER_ERROR, "%s" % messages.INTERNAL_SERVER_ERROR)
@users_ns.response(
HTTPStatus.INTERNAL_SERVER_ERROR, "%s" % messages.INTERNAL_SERVER_ERROR
)
@users_ns.expect(register_user_api_model, validate=True)

def post(cls):
"""
Creates a new user.
Expand All @@ -43,5 +49,3 @@ def post(cls):

# send POST /register request to MS API and return response
return post_request(f"{BASE_MS_API_URL}/register", data)


Loading

0 comments on commit 616bd93

Please sign in to comment.