diff --git a/Pipfile b/Pipfile index c85be2b..e3227e9 100644 --- a/Pipfile +++ b/Pipfile @@ -7,6 +7,7 @@ name = "pypi" django = "*" pillow = "*" django-allauth = "*" +facebook-sdk = "*" [dev-packages] diff --git a/Pipfile.lock b/Pipfile.lock index 591bbde..58b0d15 100644 --- a/Pipfile.lock +++ b/Pipfile.lock @@ -1,7 +1,7 @@ { "_meta": { "hash": { - "sha256": "e1421cd17320f95c82af2f3d13d778b50dd2205f469de423c2af03522dad1eb9" + "sha256": "1ea640c108a29904e710b20e7c66f511409eec3593b72556010dec2156cd8afe" }, "pipfile-spec": 6, "requires": { @@ -134,6 +134,14 @@ "index": "pypi", "version": "==0.45.0" }, + "facebook-sdk": { + "hashes": [ + "sha256:2e987b3e0f466a6f4ee77b935eb023dba1384134f004a2af21f1cfff7fe0806e", + "sha256:cabcd2e69ea3d9f042919c99b353df7aa1e2be86d040121f6e9f5e63c1cf0f8d" + ], + "index": "pypi", + "version": "==3.1.0" + }, "idna": { "hashes": [ "sha256:14475042e284991034cb48e06f6851428fb14c4dc953acd9be9a5e95c7b6dd7a", diff --git a/config/urls.py b/config/urls.py index 5ad6533..cad0b04 100644 --- a/config/urls.py +++ b/config/urls.py @@ -15,10 +15,12 @@ Including another URLconf """ from django.contrib import admin from django.urls import path, include +from django.conf import settings +from django.conf.urls.static import static urlpatterns = [ path('admin/', admin.site.urls), path('accounts/', include('allauth.urls')), path('', include('frame.urls')) -] +] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT) diff --git a/frame/static/frame/base.css b/frame/static/frame/base.css deleted file mode 100644 index e69de29..0000000 diff --git a/frame/static/frame/index.css b/frame/static/frame/index.css deleted file mode 100644 index e69de29..0000000 diff --git a/frame/templates/frame/base.html b/frame/templates/frame/base.html index 34ed7e0..ec185c7 100644 --- a/frame/templates/frame/base.html +++ b/frame/templates/frame/base.html @@ -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 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> {% block head %}{% endblock %} </head> <body> - <div class="root"> - {% block content %}{% endblock %} + <div class="row h-25"> + <div class="root card card-block col-sm-4 offset-sm-4 my-auto"> + {% block content %}{% endblock %} + </div> </div> </body> </html> \ No newline at end of file diff --git a/frame/templates/frame/login.html b/frame/templates/frame/login.html index 98b7e4a..4733324 100644 --- a/frame/templates/frame/login.html +++ b/frame/templates/frame/login.html @@ -3,10 +3,10 @@ {% load socialaccount %} {% 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> -<h2>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" %}">Facebook OAuth2</a> +<h2 class="text-decoration-underline">Step 1: Login</h2> +<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> {% endblock %} \ No newline at end of file diff --git a/frame/templates/frame/redirect.html b/frame/templates/frame/redirect.html index 5438585..c2b5fdf 100644 --- a/frame/templates/frame/redirect.html +++ b/frame/templates/frame/redirect.html @@ -3,7 +3,8 @@ {% load socialaccount %} {% block content %} -<h1>Welcome {{ request.user.first_name }}!</h1> -<h2>Step 2</h2> -<img src="{{ data }}" alt=""> -{% endblock %} \ No newline at end of file +<h1>Here's your new profile pic {{ request.user.first_name }}!</h1> +<h2>Just download and change your profile picture to this :)</h2> +<img src="{{ data.image.url }}" alt=""> +<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 %} diff --git a/frame/views.py b/frame/views.py index 8f302d2..62babad 100644 --- a/frame/views.py +++ b/frame/views.py @@ -1,11 +1,15 @@ from django.shortcuts import render from django.conf import settings +from allauth.socialaccount.models import SocialToken from .models import Profile from urllib.request import urlretrieve from django.core.files import File +import requests +import facebook + # Create your views here. def login(request): @@ -17,5 +21,7 @@ def redirect(request): profile.save() req = urlretrieve(profile.user.socialaccount_set.first().get_avatar_url()) 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}) \ No newline at end of file diff --git a/media/default.jpg b/media/default.jpg new file mode 100755 index 0000000..860b1f5 Binary files /dev/null and b/media/default.jpg differ diff --git a/media/frame.png b/media/frame.png index 2a47a6d..1368d36 100644 Binary files a/media/frame.png and b/media/frame.png differ