Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kendy Wong committed May 6, 2023
0 parents commit d1c3b54
Show file tree
Hide file tree
Showing 134 changed files with 1,109 additions and 0 deletions.
Binary file added db.sqlite3
Binary file not shown.
22 changes: 22 additions & 0 deletions manage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
"""Run administrative tasks."""
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'webapps2023.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)


if __name__ == '__main__':
main()
Empty file added payapp/__init__.py
Empty file.
Binary file added payapp/__pycache__/__init__.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added payapp/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added payapp/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added payapp/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added payapp/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added payapp/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file added payapp/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions payapp/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
6 changes: 6 additions & 0 deletions payapp/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class PayappConfig(AppConfig):
default_auto_field = 'django.db.models.BigAutoField'
name = 'payapp'
Empty file added payapp/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions payapp/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
30 changes: 30 additions & 0 deletions payapp/templates/paypal.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% extends 'base.html' %}

{% block content %}
<div class='container'>
<h1>This is PayPal Page</h1>
<hr />
<div id='paypal-button-container'></div>
</div>
<script src="https://www.paypal.com/sdk/js?client-id=sb&currency=USD"></script>

<script>
paypal.Buttons({
createOrder: function(data, actions) {
return actions.order.create({
purchase_units: [{
amount: {
value: '0.01'
}
}]
});
},

onApprove: function(data, actions) {
return actions.order.capture().then(function(details) {
alert('Transaction completed by' + details.payer.name.given_name + '!');
});
}
}).render('#paypal-button-container');
</script>
{% endblock %}
3 changes: 3 additions & 0 deletions payapp/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
6 changes: 6 additions & 0 deletions payapp/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.paypal, name="paypal"),
]
4 changes: 4 additions & 0 deletions payapp/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.shortcuts import render, redirect

def paypal(request):
return render(request, 'paypal.html', {})
Binary file added register/__pycache__/admin.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added register/__pycache__/apps.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added register/__pycache__/forms.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/forms.cpython-311.pyc
Binary file not shown.
Binary file added register/__pycache__/models.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added register/__pycache__/urls.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added register/__pycache__/views.cpython-310.pyc
Binary file not shown.
Binary file added register/__pycache__/views.cpython-311.pyc
Binary file not shown.
3 changes: 3 additions & 0 deletions register/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions register/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AuthenticateConfig(AppConfig):
name = 'register'
38 changes: 38 additions & 0 deletions register/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User
from django import forms

class EditProfileForm(UserChangeForm):
password = forms.CharField(label="", widget=forms.TextInput(attrs={'type':'hidden'}))
class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password',)


class SignUpForm(UserCreationForm):
email = forms.EmailField(label="", widget=forms.TextInput(attrs={'class':'form-control', 'placeholder':'Email Address'}), )
first_name = forms.CharField(label="", max_length=100, widget=forms.TextInput(attrs={'class':'form-control', 'placeholder':'First Name'}))
last_name = forms.CharField(label="", max_length=100, widget=forms.TextInput(attrs={'class':'form-control', 'placeholder':'Last Name'}))


class Meta:
model = User
fields = ('username', 'first_name', 'last_name', 'email', 'password1', 'password2',)

def __init__(self, *args, **kwargs):
super(SignUpForm, self).__init__(*args, **kwargs)

self.fields['username'].widget.attrs['class'] = 'form-control'
self.fields['username'].widget.attrs['placeholder'] = 'User Name'
self.fields['username'].label = ''
self.fields['username'].help_text = '<span class="form-text text-muted"><small>Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.</small></span>'

self.fields['password1'].widget.attrs['class'] = 'form-control'
self.fields['password1'].widget.attrs['placeholder'] = 'Password'
self.fields['password1'].label = ''
self.fields['password1'].help_text = '<ul class="form-text text-muted small"><li>Your password can\'t be too similar to your other personal information.</li><li>Your password must contain at least 4 characters.</li><li>Your password can\'t be a commonly used password.</li><li>Your password can\'t be entirely numeric.</li></ul>'

self.fields['password2'].widget.attrs['class'] = 'form-control'
self.fields['password2'].widget.attrs['placeholder'] = 'Confirm Password'
self.fields['password2'].label = ''
self.fields['password2'].help_text = '<span class="form-text text-muted"><small>Enter the same password as before, for verification.</small></span>'
Empty file added register/migrations/__init__.py
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions register/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your tests here.
37 changes: 37 additions & 0 deletions register/templates/change_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends 'base.html' %}

{% block content %}

<h2 class="text-center">Change Password</h2>


<form method="POST" action="{% url 'change_password' %}">
{% csrf_token %}

{% if form.errors %}
<div class="alert alert-warning alert-dismissable" role="alert">
<button class="close" data-dismiss="alert">
<small><sup>x</sup></small>
</button>
<p>Your Form Has Errors...</p>
{% for field in form %}
{% if field.errors %}
{{ field.errors }}
{% endif %}

{% endfor %}

</div>


{% endif %}


{{ form.as_p }}

<input type="submit" value="Change Password" class="btn btn-secondary">
</form>

<br/><br/>
{% endblock %}

40 changes: 40 additions & 0 deletions register/templates/edit_profile.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{% extends 'base.html' %}

{% block content %}

<h2 class="text-center">Edit Profile</h2>


<form method="POST" action="{% url 'edit_profile' %}">
{% csrf_token %}

{% if form.errors %}
<div class="alert alert-warning alert-dismissable" role="alert">
<button class="close" data-dismiss="alert">
<small><sup>x</sup></small>
</button>
<p>Your Form Has Errors...</p>
{% for field in form %}
{% if field.errors %}
{{ field.errors }}
{% endif %}

{% endfor %}

</div>


{% endif %}


{{ form.as_p }}


<input type="submit" value="Edit Profile" class="btn btn-secondary">
</form>
<br/>
<p><small><a href="{% url 'change_password' %}">Click Here</a> To Change Your Password</small></p>

<br/><br/>
{% endblock %}

16 changes: 16 additions & 0 deletions register/templates/home.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{% extends 'base.html' %}

{% block content %}

<h1>This is the home page</h1>

{% if user.is_authenticated %}

<p>Name: {{ user.first_name }} {{ user.last_name }}</p>
<p>Username: {{ user.username}}</p>
<p>Email: {{ user.email }}</p>

{% endif %}


{% endblock %}
25 changes: 25 additions & 0 deletions register/templates/login.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{% extends 'base.html' %}

{% block content %}

<h2 class="text-center">Login</h2>

<div class="col-md-6 offset-md-3">
<form method="POST">
{% csrf_token %}
<div class="form-group">

<input type="text" class="form-control" placeholder="Enter Username" name="username">

</div>
<div class="form-group">

<input type="password" class="form-control" placeholder="Enter Password" name="password">
</div>

<button type="submit" class="btn btn-secondary">Login</button>
</form>

</div>

{% endblock %}
37 changes: 37 additions & 0 deletions register/templates/register.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% extends 'base.html' %}

{% block content %}

<h2 class="text-center">Register</h2>

<div class="col-md-6 offset-md-3">
<form method="POST" action="{% url 'register' %}">
{% csrf_token %}

{% if form.errors %}
<div class="alert alert-warning alert-dismissable" role="alert">
<button class="close" data-dismiss="alert">
<small><sup>x</sup></small>
</button>
<p>Your Form Has Errors...</p>
{% for field in form %}
{% if field.errors %}
{{ field.errors }}
{% endif %}

{% endfor %}

</div>


{% endif %}


{{ form.as_p }}

<input type="submit" value="Register" class="btn btn-secondary">
</form>
</div>
<br/><br/>
{% endblock %}

9 changes: 9 additions & 0 deletions register/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models

# Create your tests here.
class User(models.Model):
username = models.CharField(max_length=60)
email = models.EmailField(max_length=60)
password = models.CharField(max_length=255)
firstname = models.CharField(max_length=255)
lastname = models.CharField(max_length=255)
11 changes: 11 additions & 0 deletions register/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from django.urls import path
from . import views

urlpatterns = [
path('', views.home, name="home"),
path('login/', views.login_user, name='login'),
path('logout/', views.logout_user, name='logout'),
path('register/', views.register_user, name='register'),
path('edit_profile/', views.edit_profile, name='edit_profile'),
path('change_password', views.change_password, name='change_password'),
]
Loading

0 comments on commit d1c3b54

Please sign in to comment.