Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

Update README.md #72

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
DJANGO_SETTINGS_MODULE=reango.settings.prod
DATABASE_URL=postgres://reango:@127.0.0.1:5432/reango
DATABASE_URL=sqlite:///db.sqlite3
ALLOWED_HOSTS=['*']
WEBPACK_PORT=55001
PROJECT_NAME=reango
4 changes: 2 additions & 2 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ test:
#- rabbitmq:3.6.10
variables:
DJANGO_SETTINGS_MODULE: reango.settings.testing
#DATABASE_URL: sqlite:///db.sqlite3
DATABASE_URL: postgres://reango_db_user:dbpassword@postgres:5432/reango_db
DATABASE_URL: sqlite:///db.sqlite3
#DATABASE_URL: postgres://reango_db_user:dbpassword@postgres:5432/reango_db
SELENIUM_HOST: http://selenium__standalone-chrome:4444/wd/hub
before_script:
- export DOCKER_CONTAINER_IP=`awk 'END{print $1}' /etc/hosts`
Expand Down
23 changes: 12 additions & 11 deletions lib/deps/base.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
Django==1.10.7
graphene==1.4.0
graphene-django==1.3
graphql-core==1.1
django-filter==1.0.4
django-environ==0.4.1
django-webpack-loader==0.4.1
Django==2.0.3
graphene-django==2.0.0
graphene==2.0.1 # via django-graphql-jwt, graphene-django
graphql-core==2.0 # via graphene, graphql-relay
graphql-relay==0.4.5 # via graphene
django-environ==0.4.4 # via django-graphql-jwt
django-filter==1.1
django-webpack-loader==0.5.0
django-custom-user==0.7
PyJWT==1.5.0
psycopg2==2.7.3
factory_boy==2.8.1
pytz==2017.2
PyJWT==1.6.1
psycopg2==2.7.4
factory_boy==2.10.0
pytz==2018.3
4 changes: 2 additions & 2 deletions lib/deps/prod.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
-r base.txt
waitress==1.0.1
whitenoise==3.2.2
waitress==1.1.0
whitenoise==3.3.1
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "1.0.0",
"description": "reango",
"scripts": {
"start": "yarn run clean && webpack-dev-server",
"build": "yarn run clean && NODE_ENV=production webpack",
"start": "npm run clean && webpack-dev-server",
"build": "npm run clean && NODE_ENV=production webpack",
"lint": "eslint client && prospector src--uses django --ignore-patterns */migrations",
"lint-fix": "eslint --fix client && autopep8 --in-place --aggressive --aggressive --recursive --max-line-length 79 server",
"clean": "rm -rf ./static/bundles/* ./static/index.html",
Expand Down Expand Up @@ -78,6 +78,7 @@
"webpack": "^3.8.1",
"webpack-bundle-tracker": "^0.2.0"
},
"proxy":"http://localhost:8000",
"metadata": {
"graphql": {
"schema": "./build/schema.json"
Expand Down
8 changes: 4 additions & 4 deletions server/polls/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField(auto_now_add=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True)
user = models.ForeignKey(settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)
vote_count = models.IntegerField(default=0)

def __str__(self):
Expand All @@ -21,9 +21,9 @@ def __str__(self):


class Vote(models.Model):
question = models.ForeignKey(Question)
selected_choice = models.ForeignKey(Choice)
user = models.ForeignKey(settings.AUTH_USER_MODEL)
question = models.ForeignKey(Question, on_delete=models.CASCADE)
selected_choice = models.ForeignKey(Choice, on_delete=models.CASCADE)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

class Meta:
unique_together = (
Expand Down
16 changes: 9 additions & 7 deletions server/polls/schema.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import graphene
from graphene_django.filter import DjangoFilterConnectionField
from graphene_django.types import DjangoObjectType
from graphene_django import DjangoObjectType
from graphene import relay, ObjectType

from polls import models
from users.jwt_util import get_token_user_id
Expand All @@ -10,7 +11,8 @@
class Question(DjangoObjectType):
class Meta:
model = models.Question
interfaces = (graphene.Node,)
filter_fields = '__all__'
interfaces = (relay.Node,)

has_viewer_voted = graphene.Boolean()

Expand All @@ -26,7 +28,7 @@ def resolve_has_viewer_voted(self, args, context, info):
class Choice(DjangoObjectType):
class Meta:
model = models.Choice
interfaces = (graphene.Node,)
interfaces = (relay.Node,)

vote_count = graphene.Int()

Expand All @@ -37,11 +39,11 @@ def resolve_vote_count(self, args, context, info):
class Vote(DjangoObjectType):
class Meta:
model = models.Vote
interfaces = (graphene.Node,)
interfaces = (relay.Node,)


class PollQueries(graphene.AbstractType):
question = graphene.Node.Field(Question)
class PollQueries(ObjectType):
question = relay.Node.Field(Question)
questions = DjangoFilterConnectionField(Question,
search_string=graphene.String())

Expand Down Expand Up @@ -106,6 +108,6 @@ def mutate_and_get_payload(cls, input, context, info):
return CreatePollMutation(poll=poll)


class PollMutations(graphene.AbstractType):
class PollMutations(ObjectType):
vote = VoteMutation.Field()
create_poll = CreatePollMutation.Field()
6 changes: 5 additions & 1 deletion server/reango/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,17 @@
# Ideally move env file should be outside the git repo
env_file = join(BASE_DIR, '.env')
if exists(env_file):
print(BASE_DIR,'354')
environ.Env.read_env(str(env_file))

# Define STATIC_ROOT for the collectstatic command
STATIC_ROOT = join(BASE_DIR, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = join(BASE_DIR, 'media')
MEDIA_URL = "/media/"

STATICFILES_DIRS = [
join(BASE_DIR, "static"),
]
# Application definition

INSTALLED_APPS = [
Expand Down
2 changes: 1 addition & 1 deletion server/reango/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

</head>
<body>
{% render_bundle 'vendor' %}
{% render_bundle 'vendor'%}
{% render_bundle 'app' %}
</body>
</html>
3 changes: 1 addition & 2 deletions server/users/jwt_schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from graphene import String, Union, Connection, Interface, Field
from graphene_django.types import ObjectType
from graphene import ObjectType, String, Union, Connection, Interface, Field


class TokensSuccess(ObjectType):
Expand Down
11 changes: 6 additions & 5 deletions server/users/schema/definitions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.contrib.auth import get_user_model
from graphene import Node, Field, GlobalID, String
from graphene_django.types import DjangoObjectType, ObjectType
from graphene import Field, GlobalID, String
from graphene_django import DjangoObjectType
from graphene import relay, ObjectType
from polls.schema import PollQueries
from users.jwt_schema import TokensInterface

Expand All @@ -19,12 +20,12 @@ class Meta:
'is_active',
'date_joined',
)
interfaces = (Node, TokensInterface)
interfaces = (relay.Node, TokensInterface)


class Viewer(ObjectType, PollQueries):
class Viewer(PollQueries, ObjectType):
id = GlobalID()
user = Field(UserNode, jwt_token=String())

class Meta:
interfaces = (TokensInterface,)
interfaces = (relay.Node, TokensInterface,)
4 changes: 2 additions & 2 deletions server/users/schema/mutations.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.contrib.auth import authenticate, get_user_model
from graphene import AbstractType, relay, Field, String, ObjectType, Union, List
from graphene import ObjectType, relay, Field, String, ObjectType, Union, List

from users.jwt_schema import TokensSuccess
from users.jwt_util import get_jwt_token
Expand Down Expand Up @@ -99,6 +99,6 @@ def mutate_and_get_payload(cls, input, context, info):
return SignupUserMutation(FormErrors(errors))


class UserMutations(AbstractType):
class UserMutations(ObjectType):
login = LoginMutation.Field()
signup = SignupUserMutation.Field()
4 changes: 2 additions & 2 deletions server/users/schema/queries.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from django.contrib.auth import get_user_model
from graphene import AbstractType, Field, String
from graphene import ObjectType, Field, String

from users.jwt_util import get_token_user_id
from .definitions import Viewer


class UserQueries(AbstractType):
class UserQueries(ObjectType):
viewer = Field(Viewer)

@staticmethod
Expand Down