Git Product home page Git Product logo

backend's Introduction

CodeBuddies logo All Contributors All Contributors

CodeBuddies Hangouts Platform v2.0 - from scratch

slack in contributions welcome first-timers-only Issue Stats Issue Stats License: GPL v3 code style: prettier

FAQ

What is CodeBuddies?

We're a community of independent code learners who help each other on Slack, schedule hangouts to learn with each other, contribute to a periodic anonymous crowdsourced newsletter where anyone can share a personal project or leave a shout out, and post on Facebook. We come from all over the world; there are members living in the United States, Japan, Sweden, the United Kingdom, Russia, Australia, Canada, India, and more. We accept donations and are 100% transparent on Open Collective.

Learning with each other helps us learn faster. We strive to create a safe space for anyone interested in code to talk about the learning process. The project is free and open-sourced on Github, and this app is 100% community/volunteer-built.

Join us on Slack! You can get your invite by clicking on the Slack invite button and join the community by verifying your invitation through your e-mail!

How do I contribute to this project?

Much of the work on this platform has shifted to the next version of CodeBuddies (aka CBv3), built in React + Django API instead of Meteor.

The two new repositories:

PLEASE go to contributing.md and refer to the contribution steps listed there! There are also helpful resources there, in case you get stuck. To add yourself as a contributor, please see the How do I add myself as a contributor? section.

Please check out docs.codebuddies.org for the full documentation.

What are you trying to build here?

screenshot of what we're building Credit: Ada Chiu.

Why are you building this site?

Our community spends a lot of time helping each other on our public Slack (P.S. You can get an invite here if you want to join), but it's hard to schedule screensharing/voice hangout study times via Slack, and it's also hard to know who else is online and available for joining a Hangout to work on something together. The platform we're building solves those issues.

Support CodeBuddies

You can help keep this project alive by becoming a Sponsor!

You can also support us with a monthly donation by becoming a Backer!

Backers

Thank you to @distalx, @alfougy, and @mozzadrella for supporting us on our Open Collective!

Sponsors

Thank you to DigitalOcean for sponsoring our hosting, MongoDB Atlas for sponsoring our database hosting, and StickerMule for sponsoring $50 in credits!

Powered by DigitalOcean

Hosted by MongoDB Atlas

Netlify

Thank you to StickerMule for sponsoring $50 in credits!

Who are the contributors so far?

Note: if you think you should be on this list, please fill out this form.


Linda

๐Ÿ’ฌ ๐Ÿ“ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ“‹ ๐Ÿ” ๐Ÿค” ๐Ÿ‘€ ๐Ÿ“ข

nalbina

๐Ÿ› ๐Ÿ’ป ๐Ÿ‘€

distalx

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“– ๐Ÿ“‹ ๐Ÿค” ๐Ÿš‡ ๐Ÿ‘€ ๐Ÿ”ง

Connie Leung

๐Ÿ› ๐Ÿ’ป ๐Ÿค” ๐Ÿ‘€

Ada Chiu

๐ŸŽจ ๐Ÿค”

Anbuselvan Periannan

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ’ต ๐Ÿค”

Roberto C Quezada

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿค” ๐Ÿ‘€

Will

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿค”

BethanyG

๐Ÿ’ฌ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“‹ ๐Ÿ’ก ๐Ÿค”

wuworkshop

๐Ÿ’ฌ ๐Ÿ” ๐Ÿค” ๐Ÿ‘€ ๐Ÿ’ป

Olivia Brundage

๐Ÿ’ฌ ๐Ÿ“– ๐Ÿค”

Hannan Ali

๐Ÿค”

Luke Camilleri

๐Ÿ’ป

Abhiram R

๐Ÿ’ป

Sharynne Azhar

๐Ÿ’ป

ispol

๐Ÿ’ป ๐Ÿค”

raresight

๐Ÿ“ ๐Ÿ’ป

Joel

๐Ÿ’ป

Michael

๐Ÿ’ป

Christoph Wagner

๐Ÿ’ฌ ๐Ÿ’ป

Patrick San Juan

๐Ÿ’ป ๐Ÿค”

Sheldon Barnes

๐Ÿ’ป

Sujil Anto

๐Ÿ’ป

techgeek503

๐Ÿ’ป

Omar Sanseviero

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿ“– ๐Ÿค” ๐ŸŒ โœ…

Angelo Cordon

๐Ÿ’ฌ ๐Ÿ’ป ๐ŸŽจ ๐Ÿ“– ๐Ÿค” ๐Ÿ‘€

Marc Baghdadi

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿค” ๐Ÿ‘€

Oliver Acevedo

๐Ÿ’ป

anonRegions

๐Ÿค”

ๅฒกใ€€ๅคง่ผ”๏ผˆDaisuke Oka)

๐Ÿค”

Tyler Hampton

๐Ÿค”

Alex

๐Ÿค”

grfraser

๐Ÿ’ป

Austin Ewens

๐Ÿ’ป

Jordan

๐Ÿ’ป

Jason Mabry

๐Ÿ’ป

ricjon

๐Ÿ’ป

morrme

๐Ÿ’ป

D/S

๐Ÿ’ป

Akosua

๐Ÿ’ป

Simon Brix

๐Ÿ’ป

Gabriel Ribeiro da Silva

๐Ÿ’ป

AJ Parise

๐Ÿ’ฌ ๐Ÿ’ป ๐Ÿค”

Marcia

๐Ÿ’ป

Jason Ly

๐Ÿ’ป

Raj Maurya

๐Ÿ’ป

Chris Ireland

๐Ÿ’ป

Radhika Morabia

๐Ÿ’ป ๐Ÿค” ๐Ÿ’ฌ

Gytis Daujotas

๐Ÿ’ป ๐Ÿค”

Rishabh Madan

๐Ÿ’ป

Jason Morris

๐Ÿ’ป

Rebecca Taylor

๐Ÿ’ป

Kevin Coleman

๐Ÿ’ป

Randy

๐Ÿ’ป

Dan Minshew

๐Ÿ’ป ๐Ÿ“‹

Arthur

๐Ÿ’ป ๐Ÿ’ต ๐Ÿค”

Julian Johannesen

๐Ÿ’ป ๐Ÿ“‹ ๐Ÿค”

agatac

๐Ÿ’ป

Kristina Karnitskaya

๐Ÿ’ป

Kenny Huynh

๐Ÿ’ป

Denny Scott

๐Ÿ’ป

Sarthak Batra

๐Ÿ’ป

R.Ganesh

๐Ÿ’ป

_Axieum

๐Ÿ’ป

josephkmh

๐Ÿ’ป

schoettkr

๐Ÿ’ป

Gabriel Romay Machado

๐Ÿ’ป

Lesfer Ayoub

๐Ÿ’ป

Jessica

๐Ÿ’ป

Vali Shah

๐Ÿ’ป

Steve Phillips

๐Ÿ’ฌ ๐Ÿ“

dmost1

๐Ÿ’ป

colleenboodleman

๐Ÿ’ป

Anish Singh Shekhawat

๐Ÿ’ป

Chen F.

๐Ÿ’ป ๐Ÿ“‹

Richard Tran

๐Ÿ’ป

Anna

๐Ÿ’ป

KPM

๐Ÿ’ป

Neha Batra

๐Ÿ’ป

Stratos Gerakakis

๐Ÿ’ป

Abhimithra Karthikeya

๐Ÿ’ป

Aaron Kim

๐Ÿ’ป

Harsh Vardhan

๐Ÿ’ป

ericathedev

๐Ÿ› ๐Ÿ’ป

Karthikeya Pammi

๐Ÿ’ป

Aditya Bansal

๐Ÿ’ป

Hamer Iboshi

๐Ÿ’ป

Jelani Thompson

๐Ÿ’ป

Govind Shukla

๐Ÿ’ป

mankinchi

๐Ÿ’ป

Steve Brewer

๐Ÿ’ป

Sebastian

๐Ÿ’ฌ ๐Ÿค”

Russ Eby

๐Ÿ’ฌ ๐Ÿค”

bryant tunbutr

๐Ÿค”

Albert Fougy

๐Ÿ’ต ๐Ÿค”

4imble

๐Ÿ’ฌ ๐Ÿ” ๐Ÿค”

Daniel Gillet

๐Ÿ’ฌ ๐Ÿ“‹

Judi

๐Ÿ’ฌ ๐Ÿ“‹ โœ…

Christopher Sabater Cordero

๐Ÿ’ฌ

Karyme Virginia

๐Ÿ’ฌ ๐Ÿ“‹

Matias Forbord

๐Ÿ’ฌ ๐Ÿ’ก

Gaurav Chikhale

๐Ÿ’ป ๐Ÿ“น

Emmanuel Raymond

๐Ÿ’ป

Bill Glover

๐Ÿ’ฌ ๐Ÿ“ ๐Ÿ› ๐Ÿ’ป ๐Ÿ“‹ ๐Ÿค” ๐Ÿ“น

Chuks Opia

๐Ÿ’ป

Maham Shahid

๐Ÿ’ป

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind are welcome!

backend's People

Contributors

bethanyg avatar billglover avatar brylie avatar chris48s avatar lpatmo avatar nuageklow avatar sebbel avatar tgrrr avatar watchtheblur avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backend's Issues

[Cleanup] Reduce repo size by cleaning up the .git folder

Context

We have some artifacts left over in the .git folder that we can clean up to reduce the size of the project from ~70mb to 384K. There was some discussion on Slack about this recently.

Acceptance Criteria

  • Tackle after #44
  • h/t @sunu for these findings:
$ du -sh .git                             
71M	.git
$ git filter-branch --index-filter 'git rm -r --cached --ignore-unmatch cbv3' --prune-empty -- --all
...
$ git for-each-ref --format="delete %(refname)" refs/original | git update-ref --stdin
$ git reflog expire --expire=now --all
$ git gc --prune=now
$ du -sh .git                                                                         
384K	.git
  • Reduced the size of .git folder from 71M to 384K

https://help.github.com/en/github/authenticating-to-github/removing-sensitive-data-from-a-repository

Document the use of the makemigrations command

Summary

I want to run pip install -r requirements/local.txt while inside the backend_app docker container so that I can install the taggit_serializer module, but I can't get inside it because my containers are continuously restarting.

Recreation of steps

$ docker-compose down
$ docker-compose rm
$ docker-compose up (with no -d)

Result:
image

From those error messages, I saw that a module taggit_serializer was not installed.

In a non-docker environment, normally I would pip install -r requirements/local.txt (or `pip install -r requirements.txt assuming that defaults to running the local.txt file which is specific to cookiecutter) while I am inside a virtualenv.

But because I am running docker, I'll have to run that command inside a container.

From https://stackoverflow.com/questions/56904783/how-to-install-a-python-library-to-a-pulled-docker-image, I found that I could run:

$ docker ps #check for the container ID
$ docker exec -it container_id bash

So I tried this:
image

But I keep getting the message that the container is restarting on the backend_manage and backend_app containers.

image

Am looking at https://stackoverflow.com/questions/37471929/docker-container-keeps-on-restarting-again-on-again next for hints on what I can do to solve the "container is always restarting" problem ๐Ÿ˜…

[File restructuring]Move project files to repository root

Several files were added to the project, probably by Cookiecutter Django, in a sub-directory, such as the LICENSE and .gitignore files. It is conventional to keep these files in the repository root.

It might be simpler to move all of the project files, keeping the sub-structure, to the project root.

Task

  • Move all project files under the cbv3_django_prototype directory to the repository root

Related task: #26

Tagging in the DB

Pulled from a PR conversation:

@BethanyG:

Agreed. The classic way to model something like this would be with a many-to-many and a Tags table. This was more a quick nod to the API specs, as well as an experiment with postgres JSONB capabilities. So a bit of a hand-wave.

But as this system grows, I do have a few concerns/caveats with a "simple" many-to-many Tags table:

Tags will most likely be a freeform field on the front end. I don't really see our users choosing from an epic list of tags...and the "common convention" is for users to enter what they see fit. This means writing a bunch of code to search for already existing tags and similar tags, and only add truly new/unique tags to the DB. Even with that, the Tags table will potentially be a mess of overlapping and duplicate data from the get-go. Just mocking up 28 resources for testing data created a "mess" -- and I am only one human.

Learning Paths, Hangouts, Notes and Discussions will also be tagged, I would imagine. So there will be potentially a lot of relations tracing back to the Tags table, each having overlapping, but not necessarily identical topics....so each would have to access the code for searching for existing tags/adding new tags. With virtually everything connecting to the Tags table (and it being updated a lot per user, hangout, note, discussion, etc.), it could become a bottleneck fairly quickly.

Postgres can index JSONB, and perform many of the same queries on JSONB that it can on regular data with small syntax changes. Both autocomplete and recommendations can be done (albeit not at top speed) with documents. But yes - if we are going the RDBMS route, then we shouldn't use JSONB too often, or in too many places.

One option is to use https://github.com/jazzband/django-taggit along with https://github.com/glemmaPaul/django-taggit-serializer, and customize the code so that each model has it's tags. See this for a rundown and some thoughts: https://medium.com/sthzg/a-short-exploration-of-django-taggit-bb869ea5051f.

And all that being said, I don't like how the Tags field adds an extra level right now, so I'm going to look at re-writing the serializer to omit that, and do some more digging on how Tags are implemented in other systems to see some more options. Do you have a go-to model/resource you can share?? That would be great.

@brylie:
We ended up using a lot of JSONB where I work, and it has been a bit of a wrestling match. The main take-away, from a senior developer colleague of mine, is to only use JSONB for specific optimizations and to default to using a relational model with Postgres.

As mentioned, we can use an auto-complete widget along with the django-taggit package to improve consistency and avoid bespoke tagging code.


To expand a little bit, JSONB is good to used when we need 'data locality', in effect avoiding a second query or JOIN to get a related entity.

In general, Tags are used to show related content, e.g. "resources tagged Python". I believe that it will be desirable to use these tags to create views showing similar items, resources, etc.

The performance penalty comes when we try to search within the JSONB column (even with an index) for a tag string in the name property, and then join related documents together.

For these reasons, JSONB does not seem like a good approach for tagging, particularly when the django taggit package makes a proper M2M tagging approach very straightforward.

Please excuse my directness, but I strongly recommend we use the django-taggit approach here or to omit the tagging feature from this pull request.

[File restructuring]Django apps should be defined in project root

Currently, this project is defining some Django apps in the cbv3_django_prototype/cbv3_django_prototype sub-directory. The project_name/project__name sub-directory is conventionally used for project-wide configuration. The Cookiecutter Django project may recommend a different file structure, but it is not apparent from a quick search of the documentation. However, running python manage.py startapp app_name in the project root creates the app in the project root, which is a fairly conventional project structure. This is a small mistake that is easy to fix.

Task

  • Consider reorganizing the project, so that apps are created in the project root (rather than in the nested directory)
  • Move all existing apps (namely, resources and users) to the project root

Reference

Allow developers to use local SQLite file instead of PostgreSQL

Currently, Codebuddies README says it is necessary to install PostgreSQL in order to develop the project. This may prove as an unnecessary barrier to entry, particularly for the prototypal nature of the project in its current state. Until this project is more mature (and possibly deployed at some staging server), we should allow local development to proceed with a simple SQLite database.

Task

  • Create an optional environment variable approach to allow developers to use SQLite instead of PostgreSQL

Use a shared Postman Collection

I've noticed a couple of contributors using Postman to test calls to the APIs exposed as part of the CodeBuddies backend. I would like to explore the idea of a shared Postman collection.

Why? By sharing a Postman (or equivalent) collection we should hope to see a couple of potential benefits. We would gain the ability to consistently call the API making it easier to reproduce observed behaviour. We should also expect to see new contributors finding it easier to make calls to the API.

Why now? Contributors have already started building up personal Postman collections. These get harder to merge as the collections grow.

Cost of doing nothing? If we don't adopt a shared collection we would leave it up to contributors to put together a method for making API requests. These could be documented as part of API documentation, or something as simple as a list of cURL commands.

Deploy the master branch to production

We don't yet have a production deployment of the CodeBuddies backend. We should have one.

Why?:
Deploying a publicly accessible version of the CodeBuddies backend will allow us to get feedback from the CodeBuddies community.

Why now?:
The earlier we get feedback, the easier it is to address. We have functionality that is very close to being ready for user testing. It would be good to have an environment to deploy to in time for release.

What if we don't implement?:
User testing will require users to stand up their own environments. This makes it less likely that a user will use features to accomplish real tasks.

Acceptance

  • publicly accessible deployment of the CB backend
  • publicly accessible deployment of the CB frontend
  • tagged changes to backend/master trigger a deployment of the CB backend

Edit: Removed frontend from the acceptance criteria as that is being deployed differently.

Add instructions to README for using Python virtual environment

Related to #3

The README currently says to run pip install -r requirements.txt. However, this by default will install all packages in the global Python namespace. It is more common to use a virtual environment to prevent package conflicts. Since we are not in consensus about using any higher-level Python dependency management library, let's just add instructions for using the default Python venv module.

Task

  • add instructions to README describing how to use the standard Python venv module to create a project virtual environment
  • make sure common virtual environment paths (such as .venv) are added to .gitignore

[API] Model and Serializer Changes in Support of Taggit.

Resource model and serializer changes needed to support taggit.

  • Remove JSONB field from Resources model
  • Alter Resource model to include taggit manager as show here & here
  • Customize through model to support the non-int (UUID) PK for Resources now using an int for pk in addition to the UUID4 as a guid.
  • Alter Admin interface to properly display taglist as shown here
  • Add https://github.com/glemmaPaul/django-taggit-serializer or something similar to installed packages for tag serialization Lib only returns a list, wrote custom serializer to return a list of slug:name pairs.
  • Alter the ResourceSerializer as needed to support tags
  • Alter the ResourceView as needed to support tags as nested elements.
  • Change any settings needed to support tags
  • Update test cases as needed
  • Add new tests as needed to support tags
  • Add/alter fixtures to support tags (remove extra fields and other cleanup)
  • Create fixture/load db with initial set of tags to "tag" resources with as POC.
  • Tag existing resources so that they can be used in dev.

Additional related SO posts and others for reference/tips:

Cannot access dockerized local Postgres container from Linux machine

Referring to #12 and #3.

On Fedora 30, I'm having issues using command from hackernoon article references in #12.

Ran docker run --rm --name pg-docker -e POSTGRES_PASSWORD=docker -d -p 5432:5432 -v $HOME/docker/volumes/postgres:/var/lib/postgresql/data postgres

Resulted in a hash. No container present when I used the docker ps command.

(source)
If I modify the command to: docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d postgres, I get a working container of Postgres.

Going back to the article above, I then use the command psql -h localhost -U postgres -d postgres , I get this message:

psql -h localhost -U postgres -d postgres psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql) psql: /usr/pgsql-11/lib/libpq.so.5: no version information available (required by psql) psql: could not connect to server: Connection refused Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432? could not connect to server: Connection refused Is the server running on host "localhost" (127.0.0.1) and accepting TCP/IP connections on port 5432?

I suspect this is an issue with my Fedora setup, but anyone with Linux experience would be greatly appreciated for insights.

[Testing]Improve Test Workflow execution time

The Test Workflow currently starts two optional applications during testing. Neither Mailhog or Adminer are required. Starting them during the workflow consumes unnecessary resources and may slow down execution.

Acceptance:

  • Only required services started during Test Workflow: web, app, db
  • Testing continues to execute and results remain visible

Use Pipenv for dependency management

It may be helpful to use Pipenv rather than just pip for dependency management. This is namely because project dependency updating is made simpler by Pipenv, along with a few other niceties like automatically initializing environment variables when activating the virtual environment.

[API] Change Resource Serializer to Pull `user` field values from Currently Authed User

The current resource POST (create) api will take any int value POSTed for the user field. This means, effectively, that one authorized user can "impersonate" another when it comes to creating a resource in the DB.

We don't want this to happen. Instead, the user field should be pulled from and populated by the 'username' field from the JWT token.

See this Stack Overflow Post for information on how this can be accomplished.

see DRF: Generic Views perform_create() under Save and deletion hooks for additional context.

[API] Endpoint for deleting a resource

We need to create a /resources/{resource_id} endpoint that accepts the following body:

{
"id": "7e08e0b0-da77-11e9-95c3-d20089b01401"
}

Making a DELETE request to resources/{resource_id} should result in the resource being deleted.

[enhancement] use GitHub actions to run tests on PRs

GitHub Actions provides the ability to automate development workflows including: linting, building, testing, releasing and deploying. Automation of these tasks helps reduce the workload for maintainers, but also helps ensure some consistency to workflows. It can also provide a degree of confidence to contributors that their changes won't have unintended consequences.

This issue is to set up GitHub Actions to execute tests for PRs raised by contributors.

Acceptance Criteria

  • GitHub Action workflow is triggered when a new PR is raised
  • The workflow executes manage.py test against the PR commit
  • The results of tests are visible to both contributor and maintainer

`django-rest-framework-jwt` is Unmaintained as of 8/2019 Replace

Since we followed a link from the DRF docs and a related tutorial directly to PyPI (where the status is not listed), we missed that https://github.com/jpadilla/django-rest-framework-jwt is unmaintained a of 8/2019. See issue jpadilla/django-rest-framework-jwt#484. We will now need to replace it.

One recommended route is to use https://github.com/davesque/django-rest-framework-simplejwt. The two libraries look similar at first glance, so the hope is the replacement will be fairly straightforward.

Using: "drop-in fork" at https://github.com/Styria-Digital/django-rest-framework-jwt.

Moving to a feature-branch style of development

I'm running across an issue contributing to Bill's contributing to this project (his fork: https://github.com/billglover/django-concept). This to help complete issue #44 .

I've attempted to fork his fork, but realize that GitHub considers it part of the same repository (I think), and so even after renaming my current fork of the official CB repo, GitHub still won't let me fork Bill's fork of this repo (sorry for all the spamming of fork and repo!).

Screenshot from 2020-01-20 21-52-59

This made me realize that using a feature branch for things like our development setup and then sub-branches for docker-compose setups would make group contributions easier.

Possible user story (draft)

As a user, I'll be like:
1/ "I want to learn Python!"
2/ Search for all resources tagged python
3/ Filter resources by paid/level
4/ Bookmark the ones that look interesting
5/ Click into a group and find ideas of hangout pairing proposals. Also be able to start a discussion thread for the group.
6/ See list of other users who joined that group, and their timezones
7/ See all the resources listed under that group (we need to figure out: who has permissions to move resources under a group??)
8/ Leave notes (either private or public) about a particular resource, and see other public notes about it.
9/ Start a discussion thread around a resource.
9/ Look at a calendar of upcoming public hangouts in the group
10/ Resource page will also show upcoming hangouts within groups the resource belongs to
11/ Have a study paths profile-y page where I can see my study path and also edit my profile info containing things like my CB Connect info, timezone, and availability this week

Set up JWT authorization & tests.

Set up JWT authorization on the DRF backend & test to make sure it's implemented correctly. This includes:

  • Installing the necessary components & updating the requirements.txt file.
  • Changing base.py settings to add DRF permission classes, CORS origin whitelist entries, and JWT_AUTH parameters.
  • Creating a auth endpoint for requesting JWT tokens with a username and PW
  • Creating new userauth app for user authorization, with current_user and UserList views.
  • Adding new routes to support signup, auth, and authorized users
  • Adding new serializers for decoding JWTs and for requesting a JWT on registration
  • Adding new JWT response handler in utils.py
  • Adding an appropriate auth views for returning user info based on their JWT, and for returning a JWT from a new user registration.
  • Adding appropriate tests to verify the new feature additions

[Enhancement] Dockerize everything for dev env setup?

Context

A couple of people (@bengineerdavis, @d3vild06) have brought up/asked about docker-izing the entire app with docker-compose. My take was that I didn't think it was necessary, unless the benefits (easier setup) is very clear. @billglover explored it, and recorded a screencast of it here: https://codebuddies.slack.com/archives/C04BRN86J/p1578770421053800. @kennethlove offered some suggestions to tweak the approach.

Acceptance Criteria

[ ] Explore a dockerized Django, Postgres, Mailhog, and Adminer (for viewing the DB). (Re: Mailhog -- that's fine! I expect at some point we'll be building out the transactional emails features)
[ ] Write a draft of instructions that users (like me) could test to set up the dev environment. Instructions should be friendly for those who've never used Docker before.

[Documentation] Linux setup

Context

In a hangout last week, @bengineerdavis and I discussed documenting some Linux-specific setup instructions for this project, assuming setting up postgres in a docker container is doable.

Acceptance Criteria

  • Add to the README.md a section re: Linux-specific instructions for getting the Django app running and a Docker Postgres instance running.

Relocate the Postgres container volume so it is no longer versioned

Actions

  • Confirm that repo size reduces with by adding db_data to .gitignore file. gitignore already ignores db_data

  • Confirm that leaving the volume undefined in docker-compose.yaml doesn't produce any side effects and maintains the functionality of the app.

  • Seek more feedback on whether to continue pursuing this issue.

Notes

  • When running git rm --cached db_data I get:

fatal: pathspec 'db_data' did not match any files

After eliminating local Postgres volume, current repo size seems primarily derived from these directories within the django project directory:
./resources ./users ./templates

Overview

Over on slack, we noticed that the current repo is about 73mb, which seems considerably larger than the amount of data we've put into the app.

Steps

  1. I first searched for venv in .git, which didn't return anything.

  2. Then I searched recursively for the largest sized directories/files in our repo and with sudo ls -lR | sudo du -ah | sort -n -r | head -n 30

The results:

964K ./cbv3_django_prototype
736K ./.git/objects/pack/pack-af3bbc530aded22c05b12ddc6bd8e00d44bef547.idx
680K ./cbv3_django_prototype/cbv3_django_prototype
608K ./db_data/base/16384/1255
608K ./db_data/base/13117/1255
608K ./db_data/base/13116/1255
608K ./db_data/base/1/1255
584K ./db_data/global
496K ./db_data/base/16384/1249
472K ./db_data/base/16384/2608
448K ./db_data/base/13117/2608
448K ./db_data/base/13116/2608
448K ./db_data/base/1/2608
408K ./db_data/base/16384/2838
408K ./db_data/base/13117/2838
408K ./db_data/base/13116/2838
408K ./db_data/base/1/2838
400K ./db_data/base/16384/2674
392K ./db_data/base/13117/1249
392K ./db_data/base/13116/1249
392K ./db_data/base/1/1249
368K ./db_data/base/13117/2674
368K ./db_data/base/13116/2674
368K ./db_data/base/1/2674
360K ./db_data/base/16384/2673
328K ./db_data/base/16384/2609
328K ./db_data/base/13117/2673
328K ./db_data/base/13117/2609
328K ./db_data/base/13116/2673
328K ./db_data/base/13116/2609

I had to run sudo because db_data is the local volume associated with our db Postgres container, which will always made modifications to files with privileged access. I spoke with @BethanyG and @angelocordon, and we agreed that this volume should never be in the git-versioned files.

Machine

Fedora 30 (Linux)

Options

.gitignore da_data

However, this is more of a bandaid, since the volume is still in the project directory.

Let docker-compose abstract the local volume setup

This will make access to the volume files trickier, but can remove a manual config step that we might not need to worry about anyway.

Rename model fields

Formerly named:

  • credit, referrer

Add:

    # specific URL of resource
    url = models.URLField(max_length=300)

    # the URL of the referring/source site.  e.g. URL of tweet, if it was tweeted.
    referring_url = models.URLField(blank=True, max_length=300)

    # names of persons who suggest this resource to the user
    referring_user = models.CharField(max_length=100)

Add instructions for setting up postgres locally (for new contributors)

Some of my notes from when I set it up locally (with @BethanyG's help):

- Set up postgres: https://wiki.postgresql.org/wiki/First_steps
- https://gist.github.com/ibraheem4/ce5ccd3e4d7a65589ce84f2a3b7c23a3
- createuser --interactive --pwprompt
- createdb cbv3

I'll need to double check exactly what I did. Luckily I still have the recording of it!

Initial data for Resources model

Adding test data to the DB, will give you a dump as soon as I'm done.  It will be about 30 resources with URLS, tags, and fake "recommenders"
the tags field will be JSONB.  This is the format:
[{
            "id": "20fba58a-2702-4378-b0f9-5ac0193d4965",
            "name": "Django"
        },
        {
            "id": "32cd4ddc-6a8e-48b2-be60-45de1784e5c7",
            "name": "Python"
        }, {
            "id": "f81f08af-6bdd-465f-8aba-1693e7348f7d",
            "name": "REST"
        }
    ]```

Requirements/base.txt cleanup

Context

base.txt seems to hold some artifacts of a pip freeze at the moment, including a pkg-resources=0.0.0 package that needs to be removed.

Acceptance criteria

[ ] Remove the pkg-resources=0.0.0 package
[ ] Clean up base.txt

Return HTTP 500 errors as JSON instead of HTML

Requests that result in an HTTP 500 Internal Server Error status code return HTML even if the client is expecting to receive a JSON response. A standard JSON error response format should be adopted to be sympathetic to client error handling code.

Why?
When the server returns an error, the client (React front end, mobile app, CLI, etc.) will want to parse that error and take appropriate action. In some cases this will be displaying a message to the user, in other it may be retrying the request or logging the error. If the client is expecting to parse a JSON response and it receives HTML it will fail to parse details of the error.

Why now?
If we introduce inconsistencies in the way the server responds with errors, we make it difficult to write clients. Clients become increasingly complex to handle these inconsistencies and it gets harder to retrofit consistency.

Cost of doing nothing?
In the case of a HTTP 500 Internal Server Error clients could look at the HTTP status code in the response and decide not to parse the response body. This workaround would avoid the need for complex error handling logic, but would reduce the information that clients could determine about the cause of the error.

[discussion] re-name this repository

The proposal is that we rename this repository to backend.

Why: Now that we have decided to use Django as the back-end for future versions of CodeBuddies, it no longer makes sense to retain the django-concept name. Calling this backend will make it clearer to contributors what the role of the repository is.

Why now: We have just force pushed a solution to #53 causing disruption to anyone who had forked the repository. Renaming the repository is disruptive and doing so now will ensure we minimise disruption to anyone working with remote or forked copies of the repo.

What if we don't do anything: If we don't make this change, we will either retain the confusing repository name or we will have to perform this disruptive change in the future when it risks being disruptive to more contributors.

[API] Endpoint for editing (PATCHing) a resource

We need a resources/{resource_id} endpoint that accepts the following JSON body:

{
      "id": "7e08e0b0-da77-11e9-95c3-d20089b01401",
      "title": "The Road to Learn React",
      "description": "This Book is your personal start of learning React and its ecosystem. You will learn plain React, transition from JavaScript ES5 to ES6, and build an application along the way. Afterward you are able to build your own applications and you are prepared to dive into the React ecosystem.",
      "url": "https://leanpub.com/the-road-to-learn-react",
      "referrer": "https://roadtoreact.com/",
      "credit": "Lynnea Sauvage ([email protected])",
      "date_published": "2019-09-18T17:50:36-07:00",
      "created": "2019-09-18T17:50:36.198968-07:00",
      "modified": "2019-09-18T17:50:36-07:00",
      "media_type": "Book",
      "paid": true,
      "tags": [
        {
          "id": "a1167632-abb8-4ce1-b090-b84e79c94c7f",
          "name": "JavaScript"
        },
        {
          "id": "66cc3539-6705-45ee-b15d-644d5fb90c41",
          "name": "ES6"
        },
        {
          "id": "8b99bcd9-a9a5-4455-b2da-fed06051d502",
          "name": "React"
        }
      ]
    }

Making a PATCH to this endpoint should result in the resource that was IDed being updated.

[API] Endpoint for creating a new resource

We need a resources/create endpoint that accepts the following JSON body:

{
      "id": "7e08e0b0-da77-11e9-95c3-d20089b01401",
      "title": "The Road to Learn React",
      "description": "This Book is your personal start of learning React and its ecosystem. You will learn plain React, transition from JavaScript ES5 to ES6, and build an application along the way. Afterward you are able to build your own applications and you are prepared to dive into the React ecosystem.",
      "url": "https://leanpub.com/the-road-to-learn-react",
      "referrer": "https://roadtoreact.com/",
      "credit": "Lynnea Sauvage ([email protected])",
      "date_published": "2019-09-18T17:50:36-07:00",
      "created": "2019-09-18T17:50:36.198968-07:00",
      "modified": "2019-09-18T17:50:36-07:00",
      "media_type": "Book",
      "paid": true,
      "tags": [
        {
          "id": "a1167632-abb8-4ce1-b090-b84e79c94c7f",
          "name": "JavaScript"
        },
        {
          "id": "66cc3539-6705-45ee-b15d-644d5fb90c41",
          "name": "ES6"
        },
        {
          "id": "8b99bcd9-a9a5-4455-b2da-fed06051d502",
          "name": "React"
        }
      ]
    }

POSTing to resources/create should result in new resource being created.

Add default GitHub Python .gitignore

There are some everyday things to put in a .gitignore file for a Python project. So, GitHub offers a default template.

Task

  • Add the default GitHub .gitignore file to this project

Clean up "cbv3" Python environment from repository

There is a folder in the repository root called "cbv3". It appears to be a local Python virtual environment. The virtual environment was likely checked in by accident, as it is unconventional to keep Python virtual environments under revision control.

Task

  • Remove the "cbv3" Python environment from the repository

UUID for Tags??

Putting this here for discussion. As currently modeled, our Resources have a JSON field with tags that have a UUID and a text string. We may decide to change this, but for now that is the model. The current UUIDs are below. Should we continue in this pattern, or should we not assign UUIDs to tags?

UUID Tag Name
20fba58a-2702-4378-b0f9-5ac0193d4965 Django
32cd4ddc-6a8e-48b2-be60-45de1784e5c7 Python
f81f08af-6bdd-465f-8aba-1693e7348f7d REST
d4ab862d-1746-4cd3-a91a-a861e2a6c5a1 Go
a1167632-abb8-4ce1-b090-b84e79c94c7f JavaScript
66cc3539-6705-45ee-b15d-644d5fb90c41 ES6
c265a4fe-d03f-445d-805f-477e05d9f4cb Node
e7891e62-8934-486e-8085-09f557bf06f6 HTML5
f9be333e-37c7-4eb1-9b0a-44bd782dab9f CSS
eab9af24-7e12-440c-bf81-48a8646b6825 LESS
7a544998-cc89-4f25-8010-be7012a615d6 SASS
446bd3dd-2190-4747-8a43-fcb0455ae660 Vue
c368c671-4083-4d2d-b4e7-2047a889249d Java
8b99bcd9-a9a5-4455-b2da-fed06051d502 React
4ddfcfff-1072-4f58-b784-02d21962f405 GraphQL
28be75b0-35cb-4e6b-ba7c-b7ecc9b17a99 Flask
e0dd22e2-bb8d-42e9-a69c-9e16c587182f Ruby
8747c553-8720-4c38-8008-1f935092819a Rails
46db9c68-70f6-4e8f-b8fc-e2cf2b347cd5 Serverless
f9680bf4-e54b-43a9-a7a8-fe795b4ce87b AWS
ce9d8208-cb7c-4d1e-afe9-c7cda11afffe SQL
dde07882-276f-4539-bdcc-e9b769455b78 Postgres
4200aed9-f773-4cee-ac5a-301dc7a646e7 Frameworks
0d325a30-7262-4914-90fe-6c90ac725fc2 FrontEnd
a442f459-74bf-4206-addc-432680f11c44 Redux
e02e9635-be20-4063-9baa-46af17e33811 .NET
48c0e583-9fed-49a1-b1a3-0f2daea4fa97 Algorithms
cd8f53dd-baa4-43b5-a869-1fc1541c67ec CS
7ac87ffc-051d-46f8-8f9c-cc4fd8a4df74 Career
faf79c64-7722-4b00-84c0-a805cf3f4b16 Interviews
3e73c86f-fadf-48fb-ae1e-6b847e3934eb Angular
96c2e86f-af02-44fb-ba80-4480efc95324 TypeScript
c0f3c83d-bb25-4746-ad44-0fbb9a660e17 Podcast
ba7b7dbb-d082-4ff0-905e-522b30aaec2c BackEnd
b864f017-91de-48f6-a02b-b903abe4ecb3 Databases
75af4e8f-6bdf-486e-97cd-13e8d434e398 Docker
c0142708-7ead-4bbd-b12a-7581a1056317 Swagger
30ab42c3-ced3-443b-ac41-332ec3d1dc60 Postman
2b6f204d-0338-41ca-a82a-5c3c759ff510 Tools
43c5b3e0-7eb6-405b-9db2-7540fba679d5 apis
8cef0a7e-63b4-4dbf-b942-1f8355c8ab45 Data Science
86a8f01e-3390-41c7-a23a-7d603815ec02 Design
6f45bbb4-f78c-4a81-9b50-210fe6c5ad27 Ethics in CS
5519988f-bebd-46c3-9d9b-4e02642faddc Code Reviews
2bf14dc6-a66c-4ff1-b75d-4d1051e1242a Functional Programming
44929775-9bb4-4840-af64-c6b0649d6677 Elm
bff25abb-9589-45db-8113-c762a3966690 Math
bb5a617c-0a92-48c7-a786-de89b7ace93a Automation
0ed56654-4752-4d35-aa8e-25ee1fcfd24e Security

[Content] Update Django home page with some getting started tips

Context

@d3vild06 noted that the first screen users see after getting the dev environment set up (either with docker-compose up, which is being reviewed in the PR for #44 right now, or manually) is this:

image

We could add some tips to that home page content to help contributors to the Django API about how to get started.

Acceptance Criteria

(Coming soon as I figure this out too)
Initially:

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.