-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
353 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
authors/apps/articles/migrations/0002_auto_20180815_1840.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Generated by Django 2.0.7 on 2018-08-15 18:40 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import taggit.managers | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
('articles', '0001_initial'), | ||
('taggit', '0002_auto_20150616_2121'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='rating', | ||
name='user', | ||
field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_article_rating', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='comment', | ||
name='article', | ||
field=models.ForeignKey(blank=True, on_delete=django.db.models.deletion.CASCADE, related_name='user_comments', to='articles.Article'), | ||
), | ||
migrations.AddField( | ||
model_name='comment', | ||
name='author', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comment_author', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='articleimage', | ||
name='article', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='article_images', to='articles.Article'), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='author', | ||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_articles', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='dislikes', | ||
field=models.ManyToManyField(blank=True, related_name='dislikes', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='favorites', | ||
field=models.ManyToManyField(blank=True, related_name='favorites', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='likes', | ||
field=models.ManyToManyField(blank=True, related_name='likes', to=settings.AUTH_USER_MODEL), | ||
), | ||
migrations.AddField( | ||
model_name='article', | ||
name='tags', | ||
field=taggit.managers.TaggableManager(blank=True, help_text='A comma-separated list of tags.', through='taggit.TaggedItem', to='taggit.Tag', verbose_name='Tags'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import facebook | ||
from rest_framework import serializers | ||
|
||
class FacebookValidation: | ||
|
||
@staticmethod | ||
def validate_facebook_token(auth_token): | ||
|
||
try: | ||
|
||
graph = facebook.GraphAPI(access_token = auth_token, version = "2.7") | ||
|
||
profile = graph.request('/me?fields=id,name,email,picture') | ||
|
||
return profile | ||
|
||
except: | ||
|
||
raise serializers.ValidationError("The Facebook token provided is not valid!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from google.oauth2 import id_token | ||
from google.auth.transport import requests | ||
from rest_framework import serializers | ||
import os | ||
|
||
class GoogleValidation: | ||
|
||
@staticmethod | ||
def validate_google_token(google_token): | ||
|
||
CLIENT_ID = "341988301600-odl0nb10vaim96gsdhpa6vun7iog5pl0.apps.googleusercontent.com" | ||
|
||
try: | ||
idinfo = id_token.verify_oauth2_token(google_token, requests.Request(), CLIENT_ID) | ||
|
||
return idinfo | ||
|
||
|
||
except: | ||
raise serializers.ValidationError("Your google token is not valid!") | ||
|
Oops, something went wrong.