Skip to content
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
Binary file added codeara/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added codeara/__pycache__/settings.cpython-39.pyc
Binary file not shown.
Binary file added codeara/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added codeara/__pycache__/wsgi.cpython-39.pyc
Binary file not shown.
9 changes: 9 additions & 0 deletions codeara/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.github',

]

MIDDLEWARE = [
Expand Down Expand Up @@ -116,6 +117,14 @@

STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
#STATICFILES_DIRS = [
# os.path.join(BASE_DIR, 'static'),

#]
#media files
MEDIA_ROOTS = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'


AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
Expand Down
6 changes: 6 additions & 0 deletions codeara/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
from django.contrib import admin
from django.urls import path, include

from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
path('admin/', admin.site.urls),
path('compiler/', include('compiler.urls', namespace="compiler")),
path('', include('user.urls')),
path('accounts/', include('allauth.urls')),
]

if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Binary file added compiler/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added compiler/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added compiler/__pycache__/forms.cpython-39.pyc
Binary file not shown.
Binary file added compiler/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added compiler/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added compiler/__pycache__/views.cpython-39.pyc
Binary file not shown.
22 changes: 22 additions & 0 deletions compiler/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from django import forms




class UserForm(forms.ModelForm):
class Meta:
fields = [
'username',
'first_name',
'last_name',
'email',
]

class ProfileForm(forms.ModelForm):
class Meta:
fields = [
'bio',
'phone_number',
'birth_date',
'profile_image',
]
Binary file not shown.
Binary file not shown.
47 changes: 47 additions & 0 deletions compiler/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,53 @@
from django.contrib.auth.decorators import login_required
from user.models import User_profile

#new
from django.http import HttpResponse
from django.contrib.auth.mixins import LoginRequiredMixin
from django.urls import reverse_lazy
from django.contrib import messages
from .forms import UserForm, ProfileForm
from django.contrib.auth.models import User
from user.models import User_profile
from django.forms import forms
from . import views
from django.views.generic import TemplateView



class ProfileView(LoginRequiredMixin, TemplateView):
template_name = 'user/profile.html'

class ProfileView(LoginRequiredMixin, TemplateView):
user_form = UserForm
profile_form = ProfileForm
template_name = 'user/profile-update.html'

def post(self, request):

post_data= request.POST or None
file_data = request.files or None

user_form = UserForm(post_data, instance=request.user)
profile_form = ProfileForm(post_data, file_data, instance=request.user.profile)

if user_form.is_valid() and profile_form.is_valid():
user_form.save()
profile_form.save()
messages.success(request, 'Your profile was sucsessfully updated!')
return HttpResponseRedirect(reverse_lazy('profile'))

context = self.get_context_data(
user_form=user_form,
profile_form=profile_form
)
return self.render_to_response(context)

def get(self, request, *args, **kwargs):
return self.post(request,**args, **kwargs)



API_ENDPOINT = "https://api.jdoodle.com/v1/execute"

client_id = "aa3c5e94ced8d771cb0a961ce09643e1"
Expand Down
Binary file added user/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added user/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added user/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added user/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added user/__pycache__/views.cpython-39.pyc
Binary file not shown.
18 changes: 18 additions & 0 deletions user/migrations/0003_user_profile_profile_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.0.7 on 2021-01-31 07:51

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('user', '0002_auto_20200118_2214'),
]

operations = [
migrations.AddField(
model_name='user_profile',
name='profile_image',
field=models.ImageField(blank=True, default='default_avatar.png', null=True, upload_to='users/'),
),
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added user/migrations/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions user/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class User_profile(models.Model):
n_subm = models.IntegerField(default=0)
n_s_sub = models.IntegerField(default=0)
lang = models.CharField(max_length=400,blank=True)
profile_image = models.ImageField(default='default_avatar.png', upload_to='users/', null=True, blank=True)

def __str__(self):
return self.first_name
46 changes: 46 additions & 0 deletions user/templates/profile-update.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{% extends 'base.html' %}

{% load crispy_forms_tags %}

{% block content %}
<!-- Begin Page Content-->
<div class="container_fluid">

<!--Page Heading-->
<div class="d-sm-flex align-items-center justify-content-between mb-4 mt-4">
<h1 class="h3 mb-0 text-grey-800">Profile Update</h1>
</div>

<!--Main Content Here-->
<div class="card o-hidden border-0">
<div class="card-body p-0">
<div class="row">
<div class="col-lg-3">
<div class="col-lg-6">
<div class="p-5">
<div class="text-center">
<h1 class="h4 text-grey-900 mb-4">Update Your Profile</h1>>
</div>>
<from method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{user_form | crispy}}
{{profile_form | crispy}}
<button type="sumbit" class="btn btn-success btn-block">Update</button>>
</from>>
<hr>
<div class="text-center">
<a class="small" href="{% url 'home' %}">Back</a>
</div>
</div>
</div>
</div>
</div>
</div>



</div>

{% endload crispy_forms_tags %}

{% endblock content %}
1 change: 1 addition & 0 deletions user/templates/profile.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% extends 'base.html' %}
{% load static %}

{% block body %}
{% block content %}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.