-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a012567
Showing
95 changed files
with
1,529 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.contrib import admin | ||
|
||
# Register your models here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class AccountsConfig(AppConfig): | ||
name = 'accounts' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.forms import UserCreationForm | ||
|
||
class UserCreateForm(UserCreationForm): | ||
|
||
class Meta(): | ||
fields = ('username' , 'email' , 'password1' , 'password2') | ||
model = get_user_model() | ||
|
||
def __init__(self , *args , **kwargs): | ||
super().__init__(*args , **kwargs) | ||
self.fields['username'].label = 'Display Name' # setting label here like did in html files... it's mandatory | ||
self.fields['email'].label = 'Email Address' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Generated by Django 3.1 on 2020-08-25 14:19 | ||
|
||
import django.contrib.auth.models | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
('auth', '0012_alter_user_first_name_max_length'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='User', | ||
fields=[ | ||
('user_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='auth.user')), | ||
], | ||
options={ | ||
'verbose_name': 'user', | ||
'verbose_name_plural': 'users', | ||
'abstract': False, | ||
}, | ||
bases=('auth.user', models.Model), | ||
managers=[ | ||
('objects', django.contrib.auth.models.UserManager()), | ||
], | ||
), | ||
] |
Empty file.
Binary file added
BIN
+1013 Bytes
simplesocial/accounts/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+191 Bytes
simplesocial/accounts/migrations/__pycache__/__init__.cpython-38.pyc
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.db import models | ||
from django.contrib import auth | ||
# Create your models here. | ||
|
||
class User(auth.models.User , auth.models.PermissionsMixin): # all work is done by django.. | ||
|
||
def __str__(self): | ||
return '@{}'.format(self.username) # username comes with class User |
17 changes: 17 additions & 0 deletions
17
simplesocial/accounts/templates/accounts/change_password.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends "base.html" %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
|
||
<div class="container"> | ||
<h1>Change Password</h1> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-default" value="Change Password"> | ||
|
||
</form> | ||
|
||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{% extends 'base.html' %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
|
||
<div class="container"> | ||
<h1>Log In</h1> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-default" value="Log In"> | ||
<a href="{% url 'accounts:password_reset' %}"> Forgot Password? </a> | ||
|
||
</form> | ||
|
||
</div> | ||
|
||
{% endblock %} |
7 changes: 7 additions & 0 deletions
7
simplesocial/accounts/templates/accounts/password_reset_complete.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<p> | ||
Your password has been set. You may go ahead and <a href="{% url 'accounts:login' %}"> Login </a> now. | ||
</p> | ||
{% endblock %} |
26 changes: 26 additions & 0 deletions
26
simplesocial/accounts/templates/accounts/password_reset_confirm.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{% extends 'base.html' %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
|
||
{% if validlink %} | ||
<h3>Change password</h3> | ||
|
||
<form method="POST"> | ||
|
||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-default" value="Submit"> | ||
|
||
</form> | ||
|
||
{% else %} | ||
|
||
<p> | ||
The password reset link was invalid, possibly because it has already been used. | ||
Please request a new password reset. | ||
</p> | ||
|
||
{% endif %} | ||
|
||
{% endblock %} |
12 changes: 12 additions & 0 deletions
12
simplesocial/accounts/templates/accounts/password_reset_done.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{% extends 'base.html' %} | ||
|
||
{% block content %} | ||
<p> | ||
We've emailed you instructions for setting your password, if an account exists with the email you entered. | ||
You should receive them shortly. | ||
</p> | ||
<p> | ||
If you don't receive an email, please make sure you've entered the address you registered with, | ||
and check your spam folder. | ||
</p> | ||
{% endblock %} |
41 changes: 41 additions & 0 deletions
41
simplesocial/accounts/templates/accounts/password_reset_email.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- {% autoescape off %} | ||
To initiate the password reset process for your {{ user.get_username }} TestSite Account, | ||
click the link below: | ||
{{ protocol }}://{{ domain }}{% url 'accounts:password_reset_confirm' uidb64=uid token=token %} | ||
If clicking the link above doesn't work, please copy and paste the URL in a new browser | ||
window instead. | ||
Sincerely, | ||
The TestSite Team | ||
{% endautoescape %} | ||
<!-- {% load i18n %} --> | ||
|
||
{% load i18n %} | ||
{% autoescape off %} | ||
|
||
{% blocktrans %} | ||
You're receiving this email because you requested a password reset for your user account at {{ site_name }}. | ||
{% endblocktrans %} | ||
|
||
{% trans "Please go to the following page and choose a new password:" %} | ||
{% block reset_link %} | ||
|
||
{{ protocol }}://{{ domain }}{% url 'accounts:password_reset_confirm' uidb64=uid token=token %} | ||
|
||
{% endblock %} | ||
|
||
{% trans "Your username, in case you've forgotten:" %} | ||
|
||
{{ user.get_username }} | ||
|
||
{% trans "Thanks for using our site!" %} | ||
|
||
{% blocktrans %} | ||
|
||
The {{ site_name }} team | ||
|
||
{% endblocktrans %} | ||
|
||
{% endautoescape %} |
15 changes: 15 additions & 0 deletions
15
simplesocial/accounts/templates/accounts/password_reset_form.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{% extends "base.html" %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
|
||
<h3> Forgot Password </h3> | ||
<form method="POST"> | ||
|
||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-default" value="Submit"> | ||
|
||
</form> | ||
|
||
{% endblock %} |
1 change: 1 addition & 0 deletions
1
simplesocial/accounts/templates/accounts/password_reset_subject.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Social Site Password Reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{% extends 'base.html' %} | ||
{% load bootstrap3 %} | ||
|
||
{% block content %} | ||
|
||
<div class="container"> | ||
<h1>Sign Up</h1> | ||
<form method="POST"> | ||
{% csrf_token %} | ||
{% bootstrap_form form %} | ||
<input type="submit" class="btn btn-default" value="Sign Up"> | ||
|
||
</form> | ||
|
||
</div> | ||
|
||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
from django.test import TestCase | ||
|
||
# Create your tests here. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from django.urls import path , include | ||
from django.contrib.auth import views as auth_views # django has builtin login view and logout view so we dont have to create it | ||
|
||
from . import views | ||
|
||
app_name = 'accounts' | ||
urlpatterns = [ | ||
path('login/' , auth_views.LoginView.as_view(template_name = 'accounts/login.html') , name='login') , | ||
path('logout/' , auth_views.LogoutView.as_view() , name='logout') , # it will take you to home page after you logout | ||
path('signup/' , views.SignUp.as_view() , name='signup') , | ||
path('password/' , views.change_pass , name='change_password') , | ||
|
||
# for password reset... can read about reset password here - > https://simpleisbetterthancomplex.com/tutorial/2016/09/19/how-to-create-password-reset-view.html | ||
# path('' , include('django.contrib.auth.urls') ) , | ||
|
||
# OR see in that link | ||
path('password_reset/', auth_views.PasswordResetView.as_view(template_name = 'accounts/password_reset_form.html' , subject_template_name = 'accounts/password_reset_subject.txt' , email_template_name = 'accounts/password_reset_email.html') , name='password_reset'), | ||
path('password_reset/done/', auth_views.PasswordResetDoneView.as_view(template_name = 'accounts/password_reset_done.html') , name='password_reset_done'), | ||
path('reset/<uidb64>/<token>/', auth_views.PasswordResetConfirmView.as_view(template_name = 'accounts/password_reset_confirm.html') , name='password_reset_confirm'), | ||
path('reset/done/', auth_views.PasswordResetCompleteView.as_view(template_name = 'accounts/password_reset_complete.html') , name='password_reset_complete'), | ||
|
||
# path('' , include('django.contrib.auth.urls') ) , | ||
|
||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.shortcuts import render , get_object_or_404 , redirect | ||
from django.views.generic import (TemplateView , ListView , DetailView , CreateView , UpdateView , DeleteView) | ||
from django.contrib.auth.mixins import LoginRequiredMixin | ||
from django.contrib.auth.decorators import login_required | ||
from django.urls import reverse_lazy | ||
|
||
#for password change | ||
from django.contrib import messages | ||
from django.contrib.auth import update_session_auth_hash #important for changin password | ||
from django.contrib.auth.forms import PasswordChangeForm #built in form | ||
|
||
from .models import User | ||
from . import forms | ||
# Create your views here. | ||
class SignUp(CreateView): | ||
template_name = 'accounts/signup.html' | ||
form_class = forms.UserCreateForm | ||
success_url = reverse_lazy('login') # once soeomeone has signed up.. take then to login page | ||
|
||
|
||
def change_pass(request): | ||
if request.method == 'POST': | ||
form = PasswordChangeForm(request.user , request.POST) #so that form gets the authenticated user | ||
|
||
|
||
if form.is_valid(): | ||
user = form.save() | ||
update_session_auth_hash(request , user) # importatnt cos else after saving form.. user's auth session will be invalidated and he will have to login again | ||
messages.success(request , 'Your Password was succesfullu updated.') | ||
return redirect('test') | ||
|
||
else: | ||
messages.error(request , 'Form not Valid!') | ||
|
||
else: | ||
form = PasswordChangeForm(request.user) | ||
|
||
return render(request , 'accounts/change_password.html' , {'form' : form} ) |
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
from django.contrib import admin | ||
from groups.models import Group , GroupMember | ||
# Register your models here. | ||
|
||
class GroupMemberInline(admin.TabularInline): | ||
model = GroupMember # so can edit it inside from Group... since Group is it's parent | ||
|
||
admin.site.register(Group) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class GroupsConfig(AppConfig): | ||
name = 'groups' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Generated by Django 3.1 on 2020-08-29 11:21 | ||
|
||
from django.conf import settings | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Group', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=256, unique=True)), | ||
('slug', models.SlugField(allow_unicode=True, unique=True)), | ||
('descriptions', models.TextField(blank=True, default='')), | ||
('description_html', models.TextField(blank=True, default='', editable=False)), | ||
], | ||
options={ | ||
'ordering': ['name'], | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='GroupMember', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='memberships', to='groups.group')), | ||
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='user_groups', to=settings.AUTH_USER_MODEL)), | ||
], | ||
options={ | ||
'unique_together': {('group', 'user')}, | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='group', | ||
name='members', | ||
field=models.ManyToManyField(through='groups.GroupMember', to=settings.AUTH_USER_MODEL), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.1 on 2020-08-29 11:51 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('groups', '0001_initial'), | ||
] | ||
|
||
operations = [ | ||
migrations.RenameField( | ||
model_name='group', | ||
old_name='descriptions', | ||
new_name='description', | ||
), | ||
] |
Empty file.
Binary file added
BIN
+1.43 KB
simplesocial/groups/migrations/__pycache__/0001_initial.cpython-38.pyc
Binary file not shown.
Binary file added
BIN
+582 Bytes
simplesocial/groups/migrations/__pycache__/0002_auto_20200829_1651.cpython-38.pyc
Binary file not shown.
Binary file not shown.
Oops, something went wrong.