NotAnyMike / TruequeGamer

TruequeGamer.com oficial repository
0 stars 0 forks source link

Trueque Gamer

General workflow

  1. Layout: Creating the static html and the css styles with stylus
  2. React: Making the layout work dynamically with react.js
  3. Django: Adding the backend for the site

Important information

Important Commands

PostgreSQL

Useful commands

Run postgres for the very first time

Based on this tutorial

  1. Install lunchy sudo gem install lunchy
  2. Run lunchy start postgres (to stop it use lunchy stop postgres
  3. Run psql in shell
  4. in postgres shell run CREATE DATABASE <myproject>;
  5. Create the user for that db running CREATE USER <username> WITH PASSWORD 'password';
  6. Change roles by running ALTER ROLE myprojectuser SET client_encoding TO 'utf8';
  7. ALTER ROLE myprojectuser SET default_transaction_isolation TO 'read committed';
  8. ALTER ROLE myprojectuser SET timezone TO 'UTC';
  9. Grant privileges with GRANT ALL PRIVILEGES ON DATABASE <myporject> TO <user>;
  10. After creating the empty database it is important to create a super user, see the section on how to create a super user

How to create a super user

you can use this in the postgres shell (although with gae could have some preoblems, better use the django shell): UPDATE auth_user SET is_superuser=true, is_staff=ture WHERE username='MikeWoodcock'; or in django, which is not the best option:

  1. run manage.py shell
  2. from django.contrib.auth.models import User
  3. user = User.objects.get(username=username`)
  4. user.is_staff = True
  5. user.is_superuser = True
  6. user.save()

Possible errors with postgres

Google app engine

inside of the django project (at the same level of manage.py) use the following command to deploy gcloud app deploy

Proxy to connect to db

In order to be able to connect to the google cloud sql instance (postgres) follow the next steps:

  1. run curl -o cloud_sql_proxy https://dl.google.com/cloudsql/cloud_sql_proxy.darwin.amd64
  2. and then make it executable with chmod +x cloud_sql_proxy

In order to initialize the proxy

use the following command in the same directory where you downloaded cloud_slq_proxy

Using a google storage bucket

first make sure you are logged in into the correct account with gcloud config configurations activate <name>, to know which configs are use gcloud config configurations list

  1. Make sure there is not an extra folder inside the static folder of each app
  2. first run ./manage.py collectstatic
  3. upload the static files to the bucket with gsutil rsync -R static/ gs://<your-gcs-bucket>/static it sometimes will be necesary to change the rsync option because sometimes it will delete the cors file
  4. make them publicly available with gsutil defacl set public-read gs://<your-gcs-bucket>
  5. perhaps it will be necesary to change the cors settings, with gsutil cors set cors-json.file.json gs://tg-static or look here

Migrating to the new social django app

Follow the next link: here

How to move react to django?

  1. Run gulp react-prod-django
  2. Run gulp css-prod

In order to use fetch with REST framework

See here