feat: finished

This commit is contained in:
Rushil Umaretiya 2021-09-28 02:34:33 -04:00
parent c5ce1d27c2
commit 8f96fbfa2e
No known key found for this signature in database
GPG Key ID: 4E8FAF9C926AF959
11 changed files with 34 additions and 14 deletions

View File

@ -7,6 +7,7 @@ name = "pypi"
django = "*" django = "*"
pillow = "*" pillow = "*"
django-allauth = "*" django-allauth = "*"
facebook-sdk = "*"
[dev-packages] [dev-packages]

10
Pipfile.lock generated
View File

@ -1,7 +1,7 @@
{ {
"_meta": { "_meta": {
"hash": { "hash": {
"sha256": "e1421cd17320f95c82af2f3d13d778b50dd2205f469de423c2af03522dad1eb9" "sha256": "1ea640c108a29904e710b20e7c66f511409eec3593b72556010dec2156cd8afe"
}, },
"pipfile-spec": 6, "pipfile-spec": 6,
"requires": { "requires": {
@ -134,6 +134,14 @@
"index": "pypi", "index": "pypi",
"version": "==0.45.0" "version": "==0.45.0"
}, },
"facebook-sdk": {
"hashes": [
"sha256:2e987b3e0f466a6f4ee77b935eb023dba1384134f004a2af21f1cfff7fe0806e",
"sha256:cabcd2e69ea3d9f042919c99b353df7aa1e2be86d040121f6e9f5e63c1cf0f8d"
],
"index": "pypi",
"version": "==3.1.0"
},
"idna": { "idna": {
"hashes": [ "hashes": [
"sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a", "sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a",

View File

@ -15,10 +15,12 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path, include from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('accounts/', include('allauth.urls')), path('accounts/', include('allauth.urls')),
path('', include('frame.urls')) path('', include('frame.urls'))
] ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

View File

@ -11,15 +11,17 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous"> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{% static 'frame/base.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'frame/base.css' %}">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<title>SoR Frame</title> <title>SoR Frame</title>
{% block head %}{% endblock %} {% block head %}{% endblock %}
</head> </head>
<body> <body>
<div class="root"> <div class="row h-25">
{% block content %}{% endblock %} <div class="root card card-block col-sm-4 offset-sm-4 my-auto">
{% block content %}{% endblock %}
</div>
</div> </div>
</body> </body>
</html> </html>

View File

@ -3,10 +3,10 @@
{% load socialaccount %} {% load socialaccount %}
{% block content %} {% block content %}
<h1>Hey there! Looks like you want an exclusive, School of Rock profile picture frame for this year's play!</h1> <h1>Hey there! </h1>
<h5>Looks like you want an exclusive, School of Rock profile picture frame for this year's play!</h5>
<h3>You've come to the right place :)</h3> <h3>You've come to the right place :)</h3>
<h2>Step 1: Login</h2> <h2 class="text-decoration-underline">Step 1: Login</h2>
<h4>We need you to log in so we can grab your profile picture and do our magic:</h4> <a href="{% provider_login_url "facebook" method="oauth2" %}"><button class="btn btn-block btn-primary"><i class="fa fa-facebook fa-fw"></i>Login with Facebook</button></a>
<a href="{% provider_login_url "facebook" method="oauth2" %}">Facebook OAuth2</a>
{% endblock %} {% endblock %}

View File

@ -3,7 +3,8 @@
{% load socialaccount %} {% load socialaccount %}
{% block content %} {% block content %}
<h1>Welcome {{ request.user.first_name }}!</h1> <h1>Here's your new profile pic {{ request.user.first_name }}!</h1>
<h2>Step 2</h2> <h2>Just download and change your profile picture to this :)</h2>
<img src="{{ data }}" alt=""> <img src="{{ data.image.url }}" alt="">
{% endblock %} <a download="pfp.jpg" href="{{ data.image.url }}" title="Profile Picture"><button class="btn btn-secondary mt-2"><i class="fa fa-download fa-fw"></i>Download Image</button></a>
{% endblock %}

View File

@ -1,11 +1,15 @@
from django.shortcuts import render from django.shortcuts import render
from django.conf import settings from django.conf import settings
from allauth.socialaccount.models import SocialToken
from .models import Profile from .models import Profile
from urllib.request import urlretrieve from urllib.request import urlretrieve
from django.core.files import File from django.core.files import File
import requests
import facebook
# Create your views here. # Create your views here.
def login(request): def login(request):
@ -17,5 +21,7 @@ def redirect(request):
profile.save() profile.save()
req = urlretrieve(profile.user.socialaccount_set.first().get_avatar_url()) req = urlretrieve(profile.user.socialaccount_set.first().get_avatar_url())
profile.image.save("image.jpg", File(open(req[0], 'rb'))) profile.image.save("image.jpg", File(open(req[0], 'rb')))
else:
profile = Profile.objects.get(user=request.user)
return render(request, 'frame/redirect.html', context={'data': profile}) return render(request, 'frame/redirect.html', context={'data': profile})

BIN
media/default.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 197 KiB

After

Width:  |  Height:  |  Size: 53 KiB