Skip to content

Commit

Permalink
Added Files
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhjak06 committed Dec 30, 2021
1 parent 70dbe59 commit 4e12399
Show file tree
Hide file tree
Showing 316 changed files with 14,593 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/hi.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Book Space Documentation.pdf
Binary file not shown.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn hi.wsgi
Binary file added accounts/.DS_Store
Binary file not shown.
Empty file added accounts/__init__.py
Empty file.
Binary file added accounts/__pycache__/__init__.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/admin.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/apps.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/decorators.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/filters.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/forms.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/models.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/signals.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/urls.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/utils.cpython-39.pyc
Binary file not shown.
Binary file added accounts/__pycache__/views.cpython-39.pyc
Binary file not shown.
17 changes: 17 additions & 0 deletions accounts/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from django.contrib import admin

# Register your models here.

from .models import *

admin.site.register(Customer)
admin.site.register(Product)
admin.site.register(Category)
admin.site.register(Order)
admin.site.register(Contact)
admin.site.register(Donate)


admin.site.register(OrderItem)
admin.site.register(ShippingAddress)
admin.site.register(FinalOrder)
15 changes: 15 additions & 0 deletions accounts/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from django.apps import AppConfig


# class AccountsConfig(AppConfig):
# name = 'accounts'
#
# def ready(self):
# import accounts.signals


class StoreConfig(AppConfig):
name = 'accounts'

def ready(self):
import accounts.signals
40 changes: 40 additions & 0 deletions accounts/decorators.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
from django.http import HttpResponse
from django.shortcuts import redirect

def unauthenticated_user(view_func):
def wrapper_func(request, *args, **kwargs):
if request.user.is_authenticated:
return redirect('home')
else:
return view_func(request, *args, **kwargs)

return wrapper_func

def allowed_users(allowed_roles=[]):
def decorator(view_func):
def wrapper_func(request, *args, **kwargs):

group = None
if request.user.groups.exists():
group = request.user.groups.all()[0].name

if group in allowed_roles:
return view_func(request, *args, **kwargs)
else:
return HttpResponse('You are not authorized to view this page')
return wrapper_func
return decorator

def admin_only(view_func):
def wrapper_function(request, *args, **kwargs):
group = None
if request.user.groups.exists():
group = request.user.groups.all()[0].name

if group == 'customer':
return redirect('user-page')

if group == 'admin':
return view_func(request, *args, **kwargs)

return wrapper_function
27 changes: 27 additions & 0 deletions accounts/filters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import django_filters
from django_filters import DateFilter, CharFilter

from .models import *


class OrderFilter(django_filters.FilterSet):
start_date = DateFilter(field_name="date_created", lookup_expr='gte')
# end_date = DateFilter(field_name="date_created", lookup_expr='lte')
# note = CharFilter(field_name='note', lookup_expr='icontains')

class Meta:
model = Order
fields = '__all__'


class ShopFilter(django_filters.FilterSet):
# start_date = DateFilter(field_name="date_created", lookup_expr='gte')
# end_date = DateFilter(field_name="date_created", lookup_expr='lte')
name = CharFilter(field_name='name', lookup_expr='icontains')

class Meta:
model = Product
fields = ['categories', 'isbn']
# exclude = ['image', 'price', 'author', 'isbn', 'condition', 'description', 'date_created']


28 changes: 28 additions & 0 deletions accounts/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from django.forms import ModelForm
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth.models import User
from django import forms

from .models import *

class CustomerForm(ModelForm):
class Meta:
model = Customer
fields = '__all__'
exclude = ['user']

class OrderForm(ModelForm):
class Meta:
model = Order
fields = '__all__'


class CreateUserForm(UserCreationForm):
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']

class DonationForm(UserCreationForm):
class Meta:
model = Donate
fields = '__all__'
46 changes: 46 additions & 0 deletions accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Generated by Django 3.1.7 on 2021-04-01 11:40

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

initial = True

dependencies = [
]

operations = [
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, null=True)),
('email', models.CharField(max_length=200, null=True)),
('phone', models.CharField(max_length=200, null=True)),
('date_created', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, null=True)),
('price', models.FloatField()),
('description', models.CharField(max_length=200, null=True)),
('category', models.CharField(max_length=200, null=True)),
('date_created', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('date_created', models.DateTimeField(auto_now_add=True)),
('status', models.CharField(choices=[('Pending', 'Pending'), ('Out For Delivery', 'Out For Delivery'), ('Delivered', 'Delivered')], max_length=200, null=True)),
('customer', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='accounts.customer')),
('product', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to='accounts.product')),
],
),
]
25 changes: 25 additions & 0 deletions accounts/migrations/0002_auto_20210401_1159.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.7 on 2021-04-01 11:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Tag',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=200, null=True)),
],
),
migrations.AddField(
model_name='product',
name='tag',
field=models.ManyToManyField(to='accounts.Tag'),
),
]
53 changes: 53 additions & 0 deletions accounts/migrations/0003_auto_20210402_0630.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Generated by Django 3.1.7 on 2021-04-02 06:30

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0002_auto_20210401_1159'),
]

operations = [
migrations.RenameField(
model_name='product',
old_name='tag',
new_name='tags',
),
migrations.AlterField(
model_name='customer',
name='date_created',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AlterField(
model_name='order',
name='date_created',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AlterField(
model_name='order',
name='status',
field=models.CharField(choices=[('Pending', 'Pending'), ('Out for delivery', 'Out for delivery'), ('Delivered', 'Delivered')], max_length=200, null=True),
),
migrations.AlterField(
model_name='product',
name='category',
field=models.CharField(choices=[('Indoor', 'Indoor'), ('Out Door', 'Out Door')], max_length=200, null=True),
),
migrations.AlterField(
model_name='product',
name='date_created',
field=models.DateTimeField(auto_now_add=True, null=True),
),
migrations.AlterField(
model_name='product',
name='description',
field=models.CharField(blank=True, max_length=200, null=True),
),
migrations.AlterField(
model_name='product',
name='price',
field=models.FloatField(null=True),
),
]
26 changes: 26 additions & 0 deletions accounts/migrations/0004_auto_20210403_0817.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.1.7 on 2021-04-03 08:17

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('accounts', '0003_auto_20210402_0630'),
]

operations = [
migrations.AddField(
model_name='customer',
name='user',
field=models.OneToOneField(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='order',
name='note',
field=models.CharField(max_length=1000, null=True),
),
]
26 changes: 26 additions & 0 deletions accounts/migrations/0005_auto_20210403_0832.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Generated by Django 3.1.7 on 2021-04-03 08:32

from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('accounts', '0004_auto_20210403_0817'),
]

operations = [
migrations.AddField(
model_name='customer',
name='profile_pic',
field=models.ImageField(blank=True, default='profile1.png', null=True, upload_to=''),
),
migrations.AlterField(
model_name='customer',
name='user',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]
Loading

0 comments on commit 4e12399

Please sign in to comment.