Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strawberry integration #64

Merged
merged 150 commits into from
Jul 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
c980749
Create dependabot.yml
ammar-faifi Jun 8, 2022
26df2fb
Update dependabot.yml
ammar-faifi Jun 8, 2022
7fda423
Bump black from 21.12b0 to 22.3.0
dependabot[bot] Jun 8, 2022
3a3bd81
Merge pull request #10 from ammar-faifi/dependabot/pip/black-22.3.0
ammar-faifi Jun 8, 2022
9cba5e5
remove import
Jun 8, 2022
377e883
tests for model profile
Jun 8, 2022
11549ce
remove extension from defaul icon
Jun 8, 2022
014e4b9
put extension back
Jun 8, 2022
ecce9c8
finlize profile model test
Jun 9, 2022
bbee892
Merge branch 'tests' of https://github.com/ngmnm/CCWebsite into tests
Jun 9, 2022
fc5be1f
put back non-secret env vars
Jun 9, 2022
b5a2af1
add secret for dev
Jun 9, 2022
938d5fc
fil
Jun 9, 2022
463c216
ignore .env
Jun 9, 2022
f9c18ed
empty commit
Jun 9, 2022
9561bc1
add python 3.10 itno testing
Jun 9, 2022
227154b
improve reading environ var
Jun 9, 2022
0bf7627
version typo
Jun 9, 2022
936af94
empty commit
Jun 9, 2022
e6fb930
add point
Jun 9, 2022
e7cb36b
add python 3.10.5
Jun 9, 2022
bdc8cf8
add env var
Jun 9, 2022
e0c2787
add SECRET_KEY env var
Jun 9, 2022
f7db285
remove defalut
Jun 9, 2022
8ef952e
clean imports
Jun 9, 2022
1aaef22
choose DB conditionally
Jun 9, 2022
2814df7
go back prod settings
Jun 9, 2022
9f6b709
remove white noise, herku will add it
Jun 9, 2022
b455e30
roll back prod settings
Jun 9, 2022
2cd9cd5
use env variables only from env itself, drop .env
Jun 9, 2022
6f6ec73
use dev settings
Jun 9, 2022
0b7535c
replace work of maintenance with middleware
Jun 10, 2022
275094f
'/account/logout/' path is allowed
Jun 10, 2022
780ac3d
turn off RegisterView, fallback to django's one
Jun 10, 2022
5d4627e
testing views is done
Jun 10, 2022
bfd778b
add ignore testing
Jun 10, 2022
345a828
exclude roommate app tests
Jun 10, 2022
ac98894
test account only
Jun 10, 2022
7a59a59
done with register testing
Jun 10, 2022
2a9fbf7
done with test_login
Jun 10, 2022
00fca22
resset pass test done
Jun 10, 2022
e84f75d
update profile is done, TODO update pic
Jun 10, 2022
f60fdb9
done with all tests
Jun 11, 2022
a3c23f4
remove old code
Jun 13, 2022
4c3597e
old code
Jun 13, 2022
3449b4e
old code
Jun 13, 2022
b5ddbf6
ignore new env
Jun 13, 2022
c0e86a6
update pip require
Jun 13, 2022
fa13be9
comment out all graphene libs
Jun 13, 2022
4da5ddc
remove python 3.9 from testing
Jun 13, 2022
417139b
move email settings to `base.py`
Jun 13, 2022
4a7d4cc
old email verification
Jun 13, 2022
cc36c8a
add email & mutations to atrwberry_auth
Jun 13, 2022
071e7a1
add email settings
Jun 14, 2022
9c6d810
fix test_login
Jun 14, 2022
8fb4023
comment out not used mutation
Jun 14, 2022
66806d8
correct test_resset_password
Jun 14, 2022
0723634
reroute paths
Jun 14, 2022
a7b63bb
add to schema extension
Jun 14, 2022
653e45d
add queries and mutations, add types
Jun 14, 2022
df8dba1
test `me` query
Jun 14, 2022
d46b3bc
add upload profile_pic with its tests
Jun 15, 2022
15060c7
message todo
Jun 15, 2022
53b33df
add extesion , order matters
Jun 15, 2022
3ed597f
update packages
Jun 16, 2022
638a938
add update profile with OwnsObjPerm
Jun 16, 2022
3f4bf55
IsAuth perm before OwnsObjPerm
Jun 16, 2022
aa98e1a
OwnsObjPerm as a dataclass
Jun 16, 2022
a3a6fdc
add message
Jun 16, 2022
d52c3b2
run balck
Jun 16, 2022
2938804
done with tessts
Jun 16, 2022
25342a0
typo
Jun 16, 2022
59673c2
improve `me`
Jun 17, 2022
341b73b
start working on communities API
Jun 17, 2022
febc916
email is from DEFAULT
Jun 17, 2022
a1dbc6f
TextChoicesField with Enum
Jun 17, 2022
f575ca2
typo
Jun 17, 2022
c4e30a2
add community/ies query
Jun 17, 2022
7b04450
clean print
Jun 17, 2022
7de2a36
new package, update auth
Jun 17, 2022
2f2d0b5
clean
Jun 17, 2022
09421eb
improve error in profilePicUpdate
Jun 17, 2022
872f6dc
add retun type
Jun 17, 2022
52951e2
wrong import
Jun 17, 2022
4ce25eb
old lib remove
Jun 17, 2022
963eab0
add pip install django-email-verification
Jun 17, 2022
9b1df5e
add community interactions
Jun 17, 2022
1975cc7
replace __doc__
Jun 17, 2022
dd433d1
add toggle like in community
Jun 17, 2022
72465db
use Enum
Jun 17, 2022
110e8ee
add report resolver
Jun 17, 2022
2b03e3d
add strawberry_djano_plus as deprate lib
Jun 18, 2022
db5be41
user `pk`, order communities by num of likes
Jun 18, 2022
54ecd1b
format
Jun 18, 2022
16fc02a
Merge pull request #63 from ammar-faifi/strawberry
ammar-faifi Jun 18, 2022
d45cdf8
modify icon filed options
Jun 18, 2022
6e9d17f
add exception for twice reporting
Jun 18, 2022
448a1b7
community crud is done,
Jun 18, 2022
fdc9dfb
delelte lib
Jun 19, 2022
0dc895f
fix check_condition
Jun 19, 2022
6ea05a9
bump strawberry-django-plus
Jun 19, 2022
f237b46
add custom directive for future use
Jun 20, 2022
faaf9b7
comment out old code, prep for replacing
Jun 20, 2022
0aead56
add evalution shcema
Jun 20, 2022
9aca0dc
add main types, with queries
Jun 20, 2022
fb37563
department list & has_evaluated queries
Jun 20, 2022
9a684f7
done with queries
Jun 20, 2022
b55e608
require login
Jun 20, 2022
9f0cbb9
add delete evaluation
Jun 20, 2022
60d7ea8
cleaning
Jun 20, 2022
7e3c7eb
add mutations & filters
Jun 20, 2022
511fe49
add custom fields
Jun 20, 2022
3f9b474
custom fiels
Jun 20, 2022
e1ac770
update requirements
Jun 24, 2022
cb7dbad
hard add strawberry_plus
Jun 24, 2022
dd41943
custom modify
Jun 24, 2022
02b6a7b
clean imports
Jun 24, 2022
01f4d31
add constraint to limit number of eval per user&instr
Jun 24, 2022
1e6ac5d
add **kwargs
Jun 24, 2022
20fc1b7
finalize evaluaion API
Jun 24, 2022
7ae9756
fix check_condition
Jun 24, 2022
0f020ff
formattinf
Jun 24, 2022
c78a961
old code
Jun 24, 2022
710526a
add cloudinary type
Jun 24, 2022
6d36238
re name the Enum types
Jun 24, 2022
eb258a7
use `pk` instead of `id`
Jun 25, 2022
8f7694e
fix profile_pic
Jun 25, 2022
3ebfb4d
fix profile_pic
Jun 25, 2022
29acb29
make partial input
Jun 25, 2022
139f5ce
clean import
Jun 25, 2022
775f243
add owned communities
Jun 25, 2022
ec63a70
add ReportInput type
Jun 25, 2022
244a85b
add evaluation_set
Jun 25, 2022
330f84c
add count felds
Jun 25, 2022
b61345f
use custom cloudinary fiels
Jun 25, 2022
8596d4b
fix to_python
Jun 25, 2022
6448cba
fallback to prev implementaion
Jun 25, 2022
6bcbe34
last updates
Jun 26, 2022
e755fe4
bump to new versions
Jun 29, 2022
e652547
bump veroius packges
Jul 2, 2022
b9dc7d7
make deparmtents list as Enum class
Jul 2, 2022
4678c97
integrate Relay
Jul 2, 2022
b5acc7c
remofe instructor from partial type
Jul 3, 2022
e9bf2f5
downgrade `strawberry-graphql`
Jul 3, 2022
8e037da
fix DepartmentDenum
Jul 3, 2022
63c7b91
reomve hard-coded lib
Jul 4, 2022
b14819e
remove print
Jul 4, 2022
158426b
fix tests
Jul 4, 2022
faa7479
clean imports
Jul 7, 2022
cee6f7c
fix tests
Jul 7, 2022
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
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "pip" # See documentation for possible values
directory: "/" # Location of package manifests
schedule:
interval: "daily"
open-pull-requests-limit: 50
9 changes: 6 additions & 3 deletions .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,18 @@ on:
pull_request:
branches: [ main ]

env:
CLOUDINARY_API_SECRET: ${{ secrets.CLOUDINARY_API_SECRET}}
EMAIL_HOST_PASSWORD: ${{ secrets.EMAIL_HOST_PASSWORD}}

jobs:
build:

runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
python-version: [3.9.13]
python-version: [3.10.5]

steps:
- uses: actions/checkout@v2
Expand All @@ -27,5 +31,4 @@ jobs:
pip install -r requirements.txt
- name: Run Tests
run: |
python manage.py test --settings=kfupm.settings.dev

python manage.py test --settings=kfupm.settings.dev --no-input account
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ celerybeat.pid
*.sage.py

# Environments
# .env
.env
.venv
env/
env3.10/
venv/
ENV/
env.bak/
Expand Down
44 changes: 22 additions & 22 deletions account/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.contrib import admin
from .models import Profile
from django.apps import apps
from graphql_auth.models import UserStatus
# from graphql_auth.models import UserStatus
from django.contrib.auth.admin import UserAdmin
from django.core.mail import send_mail
from django.contrib.auth.models import User
Expand Down Expand Up @@ -43,14 +43,14 @@ def send_message_email(self, request, queryset):
)
print(user.email)

@admin.action(description="Create a UserStatus object")
def create_status(self, request, queryset):
for user in queryset:
try:
obj = UserStatus.objects.get_or_create(user=user)
print(obj)
except Exception as e:
print(e)
# @admin.action(description="Create a UserStatus object")
# def create_status(self, request, queryset):
# for user in queryset:
# try:
# obj = UserStatus.objects.get_or_create(user=user)
# print(obj)
# except Exception as e:
# print(e)


@admin.register(Profile)
Expand All @@ -64,21 +64,21 @@ class ProfileAdmin(admin.ModelAdmin):
# admin.site.register(model)


@admin.register(UserStatus)
class UserStatusAdmin(admin.ModelAdmin):
# @admin.register(UserStatus)
# class UserStatusAdmin(admin.ModelAdmin):

list_display = ["user", "verified", "archived"]
list_filter = ["verified"]
actions = ["make_verified", "make_unverified", "make_archived", "make_unarchived"]
# list_display = ["user", "verified", "archived"]
# list_filter = ["verified"]
# actions = ["make_verified", "make_unverified", "make_archived", "make_unarchived"]

def make_verified(self, request, queryset):
queryset.update(verified=True)
# def make_verified(self, request, queryset):
# queryset.update(verified=True)

def make_unverified(self, request, queryset):
queryset.update(verified=False)
# def make_unverified(self, request, queryset):
# queryset.update(verified=False)

def make_archived(self, request, queryset):
queryset.update(archived=True)
# def make_archived(self, request, queryset):
# queryset.update(archived=True)

def make_unarchived(self, request, queryset):
queryset.update(archived=False)
# def make_unarchived(self, request, queryset):
# queryset.update(archived=False)
36 changes: 36 additions & 0 deletions account/middleware.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import re
import sys
from urllib.parse import urlparse
import requests

from django.conf import settings
from django.core.mail import mail_managers
from django.http import HttpResponseForbidden
from django.utils.deprecation import MiddlewareMixin


Expand Down Expand Up @@ -61,3 +63,37 @@ def is_ignorable_request(self, request, uri, domain, referer):
return True

return any(pattern.search(uri) for pattern in settings.IGNORABLE_404_URLS)


class AllowOnlyStaffMiddleware(MiddlewareMixin):
'''
This middleware used after authenticating middlewares,
to block non-staff users from some urls.
'''

def is_testing(self):
'''To ignore testing.'''

if (len(sys.argv) > 0 and 'runtests' in sys.argv[0]) \
or (len(sys.argv) > 1 and sys.argv[1] == 'test'):
# python runtests.py | python manage.py test | python
# setup.py test | django-admin.py test
return True

else:
return False

def process_response(self, request, response):
ALLOWED_PATHS = [
'/account/login/',
'/account/logout/',
'/endpoint/',
]

if request.user.is_staff:
return response

else:
if request.path in ALLOWED_PATHS:
return response
return HttpResponseForbidden('Forbidden 403')
20 changes: 20 additions & 0 deletions account/migrations/0012_alter_profile_major.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.0.5 on 2022-07-02 06:34

import data
from django.db import migrations
import django_choices_field.fields


class Migration(migrations.Migration):

dependencies = [
('account', '0011_auto_20220116_1133'),
]

operations = [
migrations.AlterField(
model_name='profile',
name='major',
field=django_choices_field.fields.TextChoicesField(blank=True, choices=[('AF', 'Accounting & Finance'), ('AE', 'Aerospace Engineering'), ('ARE', 'Architectural Engineering'), ('ARC', 'Architecture'), ('CE', 'Civil & Environmental Engg'), ('CEM', 'Construction Engg & Management'), ('CHE', 'Chemical Engineering'), ('CHEM', 'Chemistry'), ('COE', 'Computer Engineering'), ('CPG', 'CPG'), ('CRP', 'City & Regional Planning'), ('ERTH', 'Earth Sciences'), ('EE', 'Electrical Engineering'), ('ELI', 'English Language Inst. (Prep)'), ('ELD', 'English Language Department'), ('FIN', 'Finance'), ('ISOM', 'Info. Systems & Operations Mgt'), ('GS', 'Global & Social Studies'), ('IAS', 'Islamic & Arabic Studies'), ('ICS', 'Information & Computer Science'), ('LS', 'Life Sciences'), ('MATH', 'Mathematics & Statistics'), ('MBA', 'Business Administration'), ('ME', 'Mechanical Engineering'), ('MGT', 'Management & Marketing'), ('PE', 'Physical Education'), ('PETE', 'Petroleum Engineering'), ('PHYS', 'Physics'), ('PSE', 'Prep Science & Engineering'), ('SE', 'Systems Engineering')], choices_enum=data.DepartmentEnum, max_length=25, null=True),
),
]
12 changes: 5 additions & 7 deletions account/models.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
from tabnanny import verbose
from django.conf import settings
from django.db import models
from django.contrib.auth.models import User
from django.urls import reverse
from PIL import Image
from cloudinary.models import CloudinaryField
from cloudinary import CloudinaryImage
from data import departments, years
from data import DepartmentEnum, years
from django.dispatch import receiver
from django.db.models.signals import post_save
from django.utils.translation import gettext as _

from cloudinary.models import CloudinaryField
from django_choices_field import TextChoicesField

# Create your models here.


Expand All @@ -32,7 +30,7 @@ class Meta:
blank=True,
max_length=350,
)
major = models.CharField(blank=True, null=True, max_length=25, choices=departments)
major = TextChoicesField(blank=True, null=True, max_length=25, choices_enum=DepartmentEnum)
year = models.CharField(blank=True, null=True, max_length=25, choices=years)
language = models.CharField(_("language"), max_length=10, default='en-US')
theme = models.CharField(_("theme"), max_length=10, default='light')
Expand Down
Loading