Giter Site home page Giter Site logo

siruku6 / life_recorder Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 2.0 276 KB

display activity log

License: MIT License

Python 67.13% Shell 0.27% Haml 24.14% Dockerfile 1.21% CSS 0.45% JavaScript 6.72% Procfile 0.08%
python3 django docker circle-ci postgresql

life_recorder's Introduction

CircleCI Status Maintainability

life_recorder

Display activity log
In the future, these logs are showed in the form of chart (perhaps...)

1. Requirement

You need to setup these and to enable docker-compose to run.

  • docker
  • docker-compose

Other Middlewares

  • pipenv
  • postgresql

*You don't have to setup these Middlewares in your OS, if you build your environment with docker and docker-compose !!

2. Development

How to build development environment?

With Docker

Click here to open! :D
  1. Create OAuth 2.0 client
    If it is necessary, please create Google client-id following this article. (Google Cloud / Creating client IDs)

  2. Copy .env

    $ cp .env.example .env
    No Name Value Example Note
    1 DEBUG True True => Display error detail on browser
    2 SECRET_KEY xxxxxx... It is for Django
    3 DB_USER user It is username of your postgresql
    4 DB_PASSWORD password It is password of your postgresql
    - - - The below variables are optional
    (not required)
    5 SOCIAL_AUTH_GOOGLE_OAUTH2_KEY 000000000000-....apps.googleusercontent.com OAuth 2.0 client ID for Google
    6 SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET xxxxxx... OAuth 2.0 client secret for Google
  3. Execute following commands

    $ docker-compose build
    $ docker-compose up -d
    $ docker attach life_recorder_web_1
    $ docker-compose exec web python manage.py createsuperuser
    >> ** Input information of your superuser! **
  4. You can run automated test by this command

    $ docker-compose exec web python manage.py test --debug-mode
    
    # I recommend following options!
    $ docker-compose exec web python manage.py test --debug-mode -v 2 --pdb --keepdb

After building environment

Access to APP

  1. You can access to

    • Django Admin
      localhost:8000/admin
    • App Top
      localhost:8000/cms
    • API Root
      localhost:8000/api/v1
  2. You can display the sample response of API
    localhost:8000/api/v1/records/?format=json

Adding pip module

If you add any pip module,
then you have to rewrite requirements.txt and rerun docker-compose build,
because pip modules are installed in Docker image according to requirements.txt.

3. Contribution

Before commit or push, please run following checks, and confirm all of them are successful!

  1. flake8

    $ docker-compose exec web flake8
  2. unittest

    $ docker-compose exec web python manage.py test --debug-mode

life_recorder's People

Contributors

deepanshusaxena1 avatar siruku6 avatar

Stargazers

 avatar

Watchers

 avatar

life_recorder's Issues

[Authentication] introduce google oauth

$ docker-compose build
$ docker-compose exec web python manage.py makemigrations
$ docker-compose exec web python manage.py migrate
# We can replace '--remote staging' to '--app your_heroku_app_name'
$ heroku config:set SOCIAL_AUTH_GOOGLE_OAUTH2_KEY='000000000000-....apps.googleusercontent.com' --remote staging
$ heroku config:set SOCIAL_AUTH_GOOGLE_OAUTH2_SECRET='xxxxxxxxxxxxxxxxxxxxxxxx' --remote staging

And add Environment Variables on web console of CircleCI.

[Authentication] improve authentication flow

We don't need to use the below articles.
But I am not satisfied with the current authentication flow of this app.

References

[Unittest] introduce `FactoryBoy` for unittest and make a file or a directory for factories

official reference of FactoryBoy

https://factoryboy.readthedocs.io/en/stable/index.html
https://faker.readthedocs.io/en/master/providers.html

other references

[bug] can't find the file to execute flake8 on circleci

Failed CI execution

https://app.circleci.com/pipelines/github/siruku6/life_recorder/158/workflows/48e6a71d-1735-41de-901d-b9377d9e28d7/jobs/451

Additional information

Though I'm not sure why this is, on the branch fix/#74 the CI execution succeeded like this.
https://app.circleci.com/pipelines/github/siruku6/life_recorder/157/workflows/4ff865f2-66d4-4950-9054-c07a207ef028

Maybe the cache is wrong for some reason, for example, because I replaced the docker image working on circleci.

[Unittest] add tests for api

Tests like followings are expected ....

  1. If there is no record, activity and activity_type, then API returns []
  2. If there is some record, activity and activity_type, then API returns array of records with key sum_time
    sum_time should be equal to the sum of spent_time every date and activity_type

[Heroku] deploy on heroku

Executed commands

$ curl https://cli-assets.heroku.com/install.sh | sh
heroku/7.49.0 linux-x64 node-v12.16.2
$ heroku -v
$ heroku login -i
$ heroku create siruku6-life-recorder --buildpack heroku/python
$ heroku apps

# Set Environment Variables into Heroku OS
# INFO: You must not set next variable !
# $ heroku config:set DISABLE_COLLECTSTATIC=1
$ heroku config:set ENVIRONMENT=HEROKU
$ python
>>> from django.core.management.utils import get_random_secret_key
>>> get_random_secret_key()
'xxxxxxxxxxxxxxxxxxxxxxxx'
>>> exit()
$ heroku config:set SECRET_KEY='xxxxxxxxxxxxxxxxxxxxxxxx'

# Install django-heroku temporarily
#   https://devcenter.heroku.com/ja/articles/django-app-configuration
$ pipenv lock -r > requirements.txt
$ git add requirements.txt
$ git commit -m "updated requirements.txt"

# Deproy Django app on heroku
$ git push heroku heroku:main
$ heroku run python manage.py migrate
$ heroku run python manage.py createsuperuser

*The environment variable DATABASE_URL is set automatically by heroku. So we don't have to set.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.