diff --git a/codeara/__pycache__/__init__.cpython-39.pyc b/codeara/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..c9c28a8 Binary files /dev/null and b/codeara/__pycache__/__init__.cpython-39.pyc differ diff --git a/codeara/__pycache__/settings.cpython-39.pyc b/codeara/__pycache__/settings.cpython-39.pyc new file mode 100644 index 0000000..3fc8c82 Binary files /dev/null and b/codeara/__pycache__/settings.cpython-39.pyc differ diff --git a/codeara/__pycache__/urls.cpython-39.pyc b/codeara/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..8687f97 Binary files /dev/null and b/codeara/__pycache__/urls.cpython-39.pyc differ diff --git a/codeara/__pycache__/wsgi.cpython-39.pyc b/codeara/__pycache__/wsgi.cpython-39.pyc new file mode 100644 index 0000000..31d0de7 Binary files /dev/null and b/codeara/__pycache__/wsgi.cpython-39.pyc differ diff --git a/codeara/settings.py b/codeara/settings.py index 17be51f..518c8a4 100644 --- a/codeara/settings.py +++ b/codeara/settings.py @@ -33,6 +33,7 @@ 'allauth.socialaccount.providers.google', 'allauth.socialaccount.providers.facebook', 'allauth.socialaccount.providers.github', + ] MIDDLEWARE = [ @@ -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', diff --git a/codeara/urls.py b/codeara/urls.py index e72c2ca..9521262 100644 --- a/codeara/urls.py +++ b/codeara/urls.py @@ -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) diff --git a/compiler/__pycache__/__init__.cpython-39.pyc b/compiler/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..3e265d8 Binary files /dev/null and b/compiler/__pycache__/__init__.cpython-39.pyc differ diff --git a/compiler/__pycache__/admin.cpython-39.pyc b/compiler/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..ec6d1e8 Binary files /dev/null and b/compiler/__pycache__/admin.cpython-39.pyc differ diff --git a/compiler/__pycache__/forms.cpython-39.pyc b/compiler/__pycache__/forms.cpython-39.pyc new file mode 100644 index 0000000..04cfb3e Binary files /dev/null and b/compiler/__pycache__/forms.cpython-39.pyc differ diff --git a/compiler/__pycache__/models.cpython-39.pyc b/compiler/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..ebccc7f Binary files /dev/null and b/compiler/__pycache__/models.cpython-39.pyc differ diff --git a/compiler/__pycache__/urls.cpython-39.pyc b/compiler/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..8d2eebd Binary files /dev/null and b/compiler/__pycache__/urls.cpython-39.pyc differ diff --git a/compiler/__pycache__/views.cpython-39.pyc b/compiler/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000..eccc9c6 Binary files /dev/null and b/compiler/__pycache__/views.cpython-39.pyc differ diff --git a/compiler/forms.py b/compiler/forms.py new file mode 100644 index 0000000..23b1e07 --- /dev/null +++ b/compiler/forms.py @@ -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', + ] \ No newline at end of file diff --git a/compiler/migrations/__pycache__/0001_initial.cpython-39.pyc b/compiler/migrations/__pycache__/0001_initial.cpython-39.pyc new file mode 100644 index 0000000..8fd9817 Binary files /dev/null and b/compiler/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/compiler/migrations/__pycache__/__init__.cpython-39.pyc b/compiler/migrations/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..532615c Binary files /dev/null and b/compiler/migrations/__pycache__/__init__.cpython-39.pyc differ diff --git a/compiler/views.py b/compiler/views.py index 8ce9ef6..083cd3b 100644 --- a/compiler/views.py +++ b/compiler/views.py @@ -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" diff --git a/user/__pycache__/__init__.cpython-39.pyc b/user/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..1e37a9f Binary files /dev/null and b/user/__pycache__/__init__.cpython-39.pyc differ diff --git a/user/__pycache__/admin.cpython-39.pyc b/user/__pycache__/admin.cpython-39.pyc new file mode 100644 index 0000000..01fd14a Binary files /dev/null and b/user/__pycache__/admin.cpython-39.pyc differ diff --git a/user/__pycache__/models.cpython-39.pyc b/user/__pycache__/models.cpython-39.pyc new file mode 100644 index 0000000..5b75602 Binary files /dev/null and b/user/__pycache__/models.cpython-39.pyc differ diff --git a/user/__pycache__/urls.cpython-39.pyc b/user/__pycache__/urls.cpython-39.pyc new file mode 100644 index 0000000..9c461be Binary files /dev/null and b/user/__pycache__/urls.cpython-39.pyc differ diff --git a/user/__pycache__/views.cpython-39.pyc b/user/__pycache__/views.cpython-39.pyc new file mode 100644 index 0000000..588d1ec Binary files /dev/null and b/user/__pycache__/views.cpython-39.pyc differ diff --git a/user/migrations/0003_user_profile_profile_image.py b/user/migrations/0003_user_profile_profile_image.py new file mode 100644 index 0000000..d4f05cd --- /dev/null +++ b/user/migrations/0003_user_profile_profile_image.py @@ -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/'), + ), + ] diff --git a/user/migrations/__pycache__/0001_initial.cpython-39.pyc b/user/migrations/__pycache__/0001_initial.cpython-39.pyc new file mode 100644 index 0000000..e2c3cc6 Binary files /dev/null and b/user/migrations/__pycache__/0001_initial.cpython-39.pyc differ diff --git a/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-39.pyc b/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-39.pyc new file mode 100644 index 0000000..7d22940 Binary files /dev/null and b/user/migrations/__pycache__/0002_auto_20200118_2214.cpython-39.pyc differ diff --git a/user/migrations/__pycache__/0003_user_profile_profile_image.cpython-39.pyc b/user/migrations/__pycache__/0003_user_profile_profile_image.cpython-39.pyc new file mode 100644 index 0000000..abe30ee Binary files /dev/null and b/user/migrations/__pycache__/0003_user_profile_profile_image.cpython-39.pyc differ diff --git a/user/migrations/__pycache__/__init__.cpython-39.pyc b/user/migrations/__pycache__/__init__.cpython-39.pyc new file mode 100644 index 0000000..a6d8277 Binary files /dev/null and b/user/migrations/__pycache__/__init__.cpython-39.pyc differ diff --git a/user/models.py b/user/models.py index ed847ce..29add18 100644 --- a/user/models.py +++ b/user/models.py @@ -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 \ No newline at end of file diff --git a/user/templates/profile-update.html b/user/templates/profile-update.html new file mode 100644 index 0000000..e3ffacb --- /dev/null +++ b/user/templates/profile-update.html @@ -0,0 +1,46 @@ +{% extends 'base.html' %} + +{% load crispy_forms_tags %} + +{% block content %} + +
+ + +
+

Profile Update

+
+ + +
+
+
+
+
+
+
+

Update Your Profile

> +
> + + {% csrf_token %} + {{user_form | crispy}} + {{profile_form | crispy}} + > + > +
+
+ Back +
+
+
+
+
+
+ + + +
+ +{% endload crispy_forms_tags %} + +{% endblock content %} \ No newline at end of file diff --git a/user/templates/profile.html b/user/templates/profile.html index 1c79523..18dcedb 100644 --- a/user/templates/profile.html +++ b/user/templates/profile.html @@ -1,4 +1,5 @@ {% extends 'base.html' %} +{% load static %} {% block body %} {% block content %} diff --git a/users/WhatsApp_Image_2020-10-02_at_2.21.27_PM_1.jpeg b/users/WhatsApp_Image_2020-10-02_at_2.21.27_PM_1.jpeg new file mode 100644 index 0000000..7d6061b Binary files /dev/null and b/users/WhatsApp_Image_2020-10-02_at_2.21.27_PM_1.jpeg differ