Skip to content

Commit c954129

Browse files
committed
updated profile
1 parent ef2cd36 commit c954129

23 files changed

+79
-145
lines changed

.env.example

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
SECRET_KEY=abcd
2-
CLIENT_ID=Googleclient_id
32
DEBUG=True
43
ALLOWED_HOSTS=localhost
54
Client_id=jdoodle_id
0 Bytes
Binary file not shown.

compiler/migrations/0001_initial.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 3.0.1 on 2019-12-26 03:26
1+
# Generated by Django 3.0.1 on 2019-12-27 04:03
22

33
from django.db import migrations, models
44

Binary file not shown.

compiler/templates/base.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<li class="dropdown">
4040
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{ user.username}} <span class="caret"></span></a>
4141
<ul class="dropdown-menu">
42-
<li><a href="{% url 'user:profile' %}">Profile</a></li>
42+
<li><a href="{% url 'user:user_detail' %}">Profile</a></li>
4343
<li><a href="{% url 'account_logout' %}">Logout</a></li>
4444
</ul>
4545
</li>

db.sqlite3

4 KB
Binary file not shown.

user/__pycache__/admin.cpython-37.pyc

82 Bytes
Binary file not shown.
95 Bytes
Binary file not shown.

user/__pycache__/urls.cpython-37.pyc

57 Bytes
Binary file not shown.

user/__pycache__/views.cpython-37.pyc

-382 Bytes
Binary file not shown.

user/admin.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
from django.contrib import admin
2-
from .models import User
2+
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
33

4-
admin.site.register(User)
4+
from .models import User_profile
5+
6+
admin.site.register(User_profile)
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Generated by Django 3.0.1 on 2019-12-27 04:03
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('user', '0001_initial'),
10+
]
11+
12+
operations = [
13+
migrations.RemoveField(
14+
model_name='user',
15+
name='person',
16+
),
17+
migrations.AddField(
18+
model_name='user',
19+
name='name',
20+
field=models.CharField(blank=True, max_length=250),
21+
),
22+
migrations.AddField(
23+
model_name='user',
24+
name='ques',
25+
field=models.IntegerField(default=0),
26+
),
27+
migrations.AddField(
28+
model_name='user',
29+
name='source_code',
30+
field=models.CharField(blank=True, max_length=4500),
31+
),
32+
]

user/migrations/0002_auto_20191225_1031.py user/migrations/0003_delete_user.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,15 @@
1-
# Generated by Django 2.1.7 on 2019-12-25 05:01
1+
# Generated by Django 3.0.1 on 2019-12-27 05:57
22

33
from django.db import migrations
44

55

66
class Migration(migrations.Migration):
77

88
dependencies = [
9-
('user', '0001_initial'),
9+
('user', '0002_auto_20191227_0933'),
1010
]
1111

1212
operations = [
13-
migrations.RemoveField(
14-
model_name='user',
15-
name='person',
16-
),
1713
migrations.DeleteModel(
1814
name='user',
1915
),

user/migrations/0003_user.py

-24
This file was deleted.
Binary file not shown.
Binary file not shown.
Binary file not shown.

user/models.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
from django.db import models
2-
from django.contrib.auth.models import User
3-
4-
class User(models.Model):
5-
name = models.CharField(max_length=250)
6-
ques = models.IntegerField(default=0)
7-
points = models.IntegerField(default=0)
8-
source_code = models.CharField(max_length=4500)
9-
2+
from django.utils import timezone
3+
from django.contrib.auth.models import AbstractUser
4+
5+
class User_profile(models.Model):
6+
name = models.CharField(max_length=200, blank=True)
7+
#user = models.OneToOneField(User)
8+
#image = models.ImageField(upload_to=get_image_path, blank=True,null=True)
9+
10+
11+
12+
def __str__(self):
13+
return self.name

user/templates/account/login.html

+5-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{% extends "account/base.html" %}
2-
{% load crispy_forms_tags %}
2+
<br><br>
33
{% load i18n %}
44
{% load account socialaccount %}
55
{% block head_title %}{% trans "Sign In" %}{% endblock %}
@@ -8,29 +8,20 @@
88
<h1>{% trans "Sign In" %}</h1>
99
<form class="login" method="POST" action="{% url 'account_login' %}">
1010
{% csrf_token %}
11-
{{ form|crispy }}
12-
{% if redirect_field_value %}
13-
<input type="hidden" name="{{ redirect_field_name }}" value="{{ redirect_field_value }}" />
14-
{% endif %}
15-
<div class="login-signup-button-container">
16-
<button class="btn btn-success login-signup-button primaryAction" type="submit">
17-
{% trans "Sign In" %}
18-
</button>
19-
</div>
2011
<div class="links">
21-
<div class="signup-link">
22-
Don't have an account ? <a href="{{ signup_url }}">Sign up</a>
23-
</div>
2412
{% get_providers as socialaccount_providers %}
2513
{% if socialaccount_providers %}
2614
<div class="social-login-bar">
27-
<div class="social-login-text">or use</div>
15+
<div class="social-login-text"></div>
2816
<a href="/accounts/google/login/?process=login">
2917
<i class="fa fa-3x fa-google"></i>
3018
</a>
3119
<a href="/accounts/github/login/?process=login">
3220
<i class="fa fa-3x fa-github"></i>
3321
</a>
22+
<a href="/accounts/facebook/login/?process=login">
23+
<i class="fa fa-3x fa-facebook"></i>
24+
</a>
3425
</div>
3526
{% endif %}
3627
</div>

user/templates/account/signup.html

-27
This file was deleted.

user/templates/profile.html

+9-42
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,11 @@
11
{% extends 'base.html' %}
2-
{% block title %}
3-
Profile
4-
{% endblock %}
5-
{% block content %}
6-
<style type="text/css">
7-
.personal{
8-
display: none;
9-
}
10-
</style>
11-
<div class='col-md-9'>
12-
{% if personal %}
13-
<h1>Hello {{ name }}</h1>
14-
{% else %}
15-
<h1>You are viewing {{name}}'s profile</h1>
16-
{% endif %}
17-
18-
<div class="panel panel-default">
19-
<div class="panel-body">
20-
<p>Total points:- {{ points }}</p>
21-
{% if solved %}
22-
<p>Solved questions:-</p>
23-
<ul class="list-group">
24-
{% for question in solved %}
25-
<li class="list-group-item">{{ question }}</li>
26-
{% endfor %}
27-
</ul>
28-
{% else %}
29-
<h4>No questions solved</h4>
30-
<a href="{% url 'alltracks' %}" class="personal">Solve questions</a>
31-
32-
33-
{% endif %}
34-
</div>
352

36-
</div>
37-
</div>
38-
39-
{% if personal %}
40-
<script type="text/javascript">
41-
$(".personal").show()
42-
</script>
43-
{% endif %}
44-
{% endblock %}
3+
{% block body %}
4+
{% block content %}
5+
{% load account socialaccount %}
6+
<div class="container login-signup-container" id="login_cont">
7+
<p>You're logged in {{ user.get_provider }} as {{ user }}.</p>
8+
<img src="{{ user.get_avatar_url }}" />
9+
</div>
10+
{% endblock content %}
11+
{% endblock body %}

user/urls.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
urlpatterns = [
99
path('', views.home, name = 'home'),
1010
path('accounts/profile/', views.profile , name = 'profile'),
11-
#path('accounts/profiles/(?P<id>\d+)', views.profiles , name = 'user_profile'),
11+
#path('accounts/profile/view/', views.user_detail, name = 'user_detail'),
12+
path('accounts/profile/view', views.user_detail, name='user_detail'),
1213
]

user/views.py

+11-18
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from django.http import HttpResponse, JsonResponse
77
import os
88
from compiler.models import Question
9+
#from user.models import User
910
from decouple import config
1011

1112
def home(request):
@@ -14,22 +15,14 @@ def home(request):
1415
question = {"q_num":ques}
1516
return render(request,"home.html", question)
1617

17-
def signup(request):
18-
if request.method == 'POST':
19-
form = UserCreationForm(request.POST)
20-
if form.is_valid():
21-
form.save()
22-
username = form.cleaned_data.get('username')
23-
raw_password = form.cleaned_data.get('password1')
24-
user = authenticate(username=username, password=raw_password)
25-
login(request, user)
26-
return redirect('code_editor.html')
27-
else:
28-
form = UserCreationForm()
29-
return render(request, 'registration/signup.html', {'form': form})
18+
def profile(request):
19+
#cur_user = request.User
20+
#usr = User.objects.get(id=cur_user.id)
21+
#usr = {"user":usr}
22+
return render(request,'code_editor.html')
23+
24+
def user_detail(request):
25+
#cur_user = request.user.get.id
26+
return render(request,'profile.html')
27+
3028

31-
def profile(requests):
32-
context = {}
33-
user = requests.user
34-
context['name']=user.username
35-
return render(requests,'code_editor.html')

0 commit comments

Comments
 (0)