First Commit
4
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"git.ignoreLimitWarning": true,
|
||||||
|
"python.pythonPath": "C:\\Users\\sir\\envs\\rohit\\Scripts\\python.exe"
|
||||||
|
}
|
||||||
0
accounts/__init__.py
Normal file
BIN
accounts/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
accounts/__pycache__/admin.cpython-37.pyc
Normal file
BIN
accounts/__pycache__/apps.cpython-37.pyc
Normal file
BIN
accounts/__pycache__/models.cpython-37.pyc
Normal file
BIN
accounts/__pycache__/urls.cpython-37.pyc
Normal file
BIN
accounts/__pycache__/views.cpython-37.pyc
Normal file
3
accounts/admin.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
# Register your models here.
|
||||||
5
accounts/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class AccountsConfig(AppConfig):
|
||||||
|
name = 'accounts'
|
||||||
0
accounts/migrations/__init__.py
Normal file
BIN
accounts/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
3
accounts/models.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.db import models
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
34
accounts/templates/login.html
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{% extends 'base.html'%}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
{{ error }}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h1> Log In </h1>
|
||||||
|
|
||||||
|
<form method="POST" action="{% url 'login' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
Username:
|
||||||
|
<br />
|
||||||
|
<input type="text" name="username" placeholder="username">
|
||||||
|
<br />
|
||||||
|
Password:
|
||||||
|
<br />
|
||||||
|
<input type="password" name="password" placeholder="password">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<input class="btn btn-primary "type="submit" value="Log In"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
38
accounts/templates/signup.html
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
{% extends 'base.html'%}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
{{ error }}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<h1> Sign Up</h1>
|
||||||
|
|
||||||
|
<form method="POST" action="{% url 'signup' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
Username:
|
||||||
|
<br />
|
||||||
|
<input type="text" name="username" placeholder="username">
|
||||||
|
<br />
|
||||||
|
Password:
|
||||||
|
<br />
|
||||||
|
<input type="password" name="password1" placeholder="password">
|
||||||
|
<br />
|
||||||
|
Confirm Password:
|
||||||
|
<br />
|
||||||
|
<input type="password" name="password2" placeholder=" confirm password">
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<input class="btn btn-primary "type="submit" value="Sign Up"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
3
accounts/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
9
accounts/urls.py
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
from django.urls import path,include
|
||||||
|
from . import views
|
||||||
|
urlpatterns = [
|
||||||
|
path('signup',views.signup, name='signup'),
|
||||||
|
path('login',views.login, name='login'),
|
||||||
|
path('logout',views.logout, name='logout'),
|
||||||
|
]
|
||||||
|
|
||||||
41
accounts/views.py
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
from django.shortcuts import render,redirect
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
from django.contrib import auth
|
||||||
|
|
||||||
|
# Create your views here.
|
||||||
|
def signup(request):
|
||||||
|
if request.method =='POST':
|
||||||
|
if request.POST['password1'] == request.POST['password2']:
|
||||||
|
try:
|
||||||
|
user=User.objects.get(username=request.POST['username'])
|
||||||
|
return render(request,'signup.html',{'error':'Username has been already taken '})
|
||||||
|
except User.DoesNotExist:
|
||||||
|
user=User.objects.create_user(request.POST['username'],password=request.POST['password1'])
|
||||||
|
auth.login(request,user)
|
||||||
|
return redirect('home')
|
||||||
|
else:
|
||||||
|
return render(request,'signup.html',{'error':'Passwords must match'})
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
return render(request,'signup.html')
|
||||||
|
|
||||||
|
def login(request):
|
||||||
|
if request.method =='POST':
|
||||||
|
user=auth.authenticate(username=request.POST['username'],password=request.POST['password'])
|
||||||
|
if user is not None:
|
||||||
|
auth.login(request,user)
|
||||||
|
return redirect('home')
|
||||||
|
else:
|
||||||
|
return render(request,'login.html', {'error':'username or password is invalid.'})
|
||||||
|
else:
|
||||||
|
return render(request,'login.html')
|
||||||
|
|
||||||
|
def logout(request):
|
||||||
|
if request.method =='POST':
|
||||||
|
auth.logout(request)
|
||||||
|
return redirect('home')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BIN
db.sqlite3
Normal file
0
heroine/__init__.py
Normal file
BIN
heroine/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
heroine/__pycache__/settings.cpython-37.pyc
Normal file
BIN
heroine/__pycache__/urls.cpython-37.pyc
Normal file
BIN
heroine/__pycache__/wsgi.cpython-37.pyc
Normal file
146
heroine/settings.py
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
"""
|
||||||
|
Django settings for heroine project.
|
||||||
|
|
||||||
|
Generated by 'django-admin startproject' using Django 2.2.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/2.2/topics/settings/
|
||||||
|
|
||||||
|
For the full list of settings and their values, see
|
||||||
|
https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||||
|
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||||
|
|
||||||
|
|
||||||
|
# Quick-start development settings - unsuitable for production
|
||||||
|
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||||
|
|
||||||
|
# SECURITY WARNING: keep the secret key used in production secret!
|
||||||
|
SECRET_KEY = '9#!(x85mkmgx!%#y@l6ei&4k7nywz*f3(qhei17oev6q28sz@q'
|
||||||
|
|
||||||
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
|
DEBUG = True
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = []
|
||||||
|
|
||||||
|
|
||||||
|
# Application definition
|
||||||
|
|
||||||
|
INSTALLED_APPS = [
|
||||||
|
'django.contrib.admin',
|
||||||
|
'django.contrib.auth',
|
||||||
|
'django.contrib.contenttypes',
|
||||||
|
'django.contrib.sessions',
|
||||||
|
'django.contrib.messages',
|
||||||
|
'django.contrib.staticfiles',
|
||||||
|
'products.apps.ProductsConfig',
|
||||||
|
'accounts.apps.AccountsConfig',
|
||||||
|
]
|
||||||
|
|
||||||
|
MIDDLEWARE = [
|
||||||
|
'django.middleware.security.SecurityMiddleware',
|
||||||
|
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||||
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.csrf.CsrfViewMiddleware',
|
||||||
|
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||||
|
'django.contrib.messages.middleware.MessageMiddleware',
|
||||||
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
|
]
|
||||||
|
|
||||||
|
ROOT_URLCONF = 'heroine.urls'
|
||||||
|
|
||||||
|
TEMPLATES = [
|
||||||
|
{
|
||||||
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|
||||||
|
|
||||||
|
'DIRS': ['heroine/templates'],
|
||||||
|
|
||||||
|
|
||||||
|
'APP_DIRS': True,
|
||||||
|
'OPTIONS': {
|
||||||
|
'context_processors': [
|
||||||
|
'django.template.context_processors.debug',
|
||||||
|
'django.template.context_processors.request',
|
||||||
|
'django.contrib.auth.context_processors.auth',
|
||||||
|
'django.contrib.messages.context_processors.messages',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
WSGI_APPLICATION = 'heroine.wsgi.application'
|
||||||
|
|
||||||
|
|
||||||
|
# Database
|
||||||
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||||
|
|
||||||
|
DATABASES = {
|
||||||
|
'default': {
|
||||||
|
'ENGINE': 'django.db.backends.postgresql',
|
||||||
|
'NAME': 'portfolio',
|
||||||
|
'USER': 'postgres',
|
||||||
|
'PASSWORD':'rohitallu',
|
||||||
|
'HOST':'localhost',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
# Password validation
|
||||||
|
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||||
|
|
||||||
|
AUTH_PASSWORD_VALIDATORS = [
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
# Internationalization
|
||||||
|
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||||
|
|
||||||
|
LANGUAGE_CODE = 'en-us'
|
||||||
|
|
||||||
|
TIME_ZONE = 'UTC'
|
||||||
|
|
||||||
|
USE_I18N = True
|
||||||
|
|
||||||
|
USE_L10N = True
|
||||||
|
|
||||||
|
USE_TZ = True
|
||||||
|
|
||||||
|
|
||||||
|
# Static files (CSS, JavaScript, Images)
|
||||||
|
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
STATICFILES_DIRS=[
|
||||||
|
os.path.join(BASE_DIR, 'heroine/static/')
|
||||||
|
]
|
||||||
|
|
||||||
|
STATIC_ROOT=os.path.join(BASE_DIR, 'static')
|
||||||
|
|
||||||
|
STATIC_URL = '/static/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MEDIA_ROOT=os.path.join(BASE_DIR, 'media')
|
||||||
|
|
||||||
|
MEDIA_URL = '/media/'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BIN
heroine/static/Thumbs.db
Normal file
BIN
heroine/static/create2.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
heroine/static/create3.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
heroine/static/new4.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
101
heroine/templates/base.html
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
|
||||||
|
<!doctype html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
{% load staticfiles %}
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="description" content="">
|
||||||
|
<meta name="author" content="Mark Otto, Jacob Thornton, and Bootstrap contributors">
|
||||||
|
<meta name="generator" content="Jekyll v3.8.6">
|
||||||
|
<title>Rohit's Products Hunt</title>
|
||||||
|
|
||||||
|
<link rel="canonical" href="https://getbootstrap.com/docs/4.4/examples/album/">
|
||||||
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||||
|
<!-- Bootstrap core CSS -->
|
||||||
|
<link href="/docs/4.4/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||||
|
|
||||||
|
<!-- Favicons -->
|
||||||
|
<link rel="apple-touch-icon" href="/docs/4.4/assets/img/favicons/apple-touch-icon.png" sizes="180x180">
|
||||||
|
<link rel="icon" href="/docs/4.4/assets/img/favicons/favicon-32x32.png" sizes="32x32" type="image/png">
|
||||||
|
<link rel="icon" href="/docs/4.4/assets/img/favicons/favicon-16x16.png" sizes="16x16" type="image/png">
|
||||||
|
<link rel="manifest" href="/docs/4.4/assets/img/favicons/manifest.json">
|
||||||
|
<link rel="mask-icon" href="/docs/4.4/assets/img/favicons/safari-pinned-tab.svg" color="#563d7c">
|
||||||
|
<link rel="icon" href="/docs/4.4/assets/img/favicons/favicon.ico">
|
||||||
|
<meta name="msapplication-config" content="/docs/4.4/assets/img/favicons/browserconfig.xml">
|
||||||
|
<meta name="theme-color" content="#563d7c">
|
||||||
|
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bd-placeholder-img {
|
||||||
|
font-size: 1.125rem;
|
||||||
|
text-anchor: middle;
|
||||||
|
-webkit-user-select: none;
|
||||||
|
-moz-user-select: none;
|
||||||
|
-ms-user-select: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 768px) {
|
||||||
|
.bd-placeholder-img-lg {
|
||||||
|
font-size: 3.5rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<!-- Custom styles for this template -->
|
||||||
|
<link href="album.css" rel="stylesheet">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<header>
|
||||||
|
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
|
||||||
|
<div class="container">
|
||||||
|
<a class="navbar-brand" href="{% url 'home' %}">
|
||||||
|
<img src="{% static 'new4.jpg' %}" height=40 width=40 class="d-inline-block alighn-top">
|
||||||
|
Product Hunt
|
||||||
|
</a>
|
||||||
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
|
||||||
|
<span class="navbar-toggler-icon"></span>
|
||||||
|
</button>
|
||||||
|
<div class="collapse navbar-collapse" id="navbarNavAltMarkup">
|
||||||
|
<div class="navbar-nav ml-auto" >
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<h1>Hello, {{user.username}}</h1>
|
||||||
|
<a class="nav-item nav-link active" href="{% url 'create' %}">
|
||||||
|
<img src="{% static 'create2.png' %}" height=30 width=40 class="d-inline-block alighn-top">
|
||||||
|
Create Product
|
||||||
|
</a>
|
||||||
|
<a class="nav-item nav-link active" href="javascript:{document.getElementById('logout').submit()}">Logout</a>
|
||||||
|
<form id="logout" method="POST" action="{% url 'logout' %}">
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden" />
|
||||||
|
</form>
|
||||||
|
{% else %}
|
||||||
|
<a class="nav-item nav-link active" href="{% url 'signup' %}">Sign Up</a>
|
||||||
|
<a class="nav-item nav-link active" href="{% url 'login' %}">Log In</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
{% block content %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<footer class="text-center">
|
||||||
|
<div class="container">
|
||||||
|
<h1>Welcome to {% now "Y" %}</h1>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
<script src="https://code.jquery.com/jquery-3.4.1.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||||
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||||
|
<script>window.jQuery || document.write('<script src="/docs/4.4/assets/js/vendor/jquery.slim.min.js"><\/script>')</script><script src="/docs/4.4/dist/js/bootstrap.bundle.min.js" integrity="sha384-6khuMg9gaYr5AxOqhkVIODVIvm9ynTT5J4V1cfthmT+emCG6yVmEZsRHdxlotUnm" crossorigin="anonymous"></script></body>
|
||||||
|
</html>
|
||||||
29
heroine/urls.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
"""heroine URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
||||||
|
Examples:
|
||||||
|
Function views
|
||||||
|
1. Add an import: from my_app import views
|
||||||
|
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||||
|
Class-based views
|
||||||
|
1. Add an import: from other_app.views import Home
|
||||||
|
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||||
|
Including another URLconf
|
||||||
|
1. Import the include() function: from django.urls import include, path
|
||||||
|
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||||
|
"""
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.urls import path,include
|
||||||
|
from products import views
|
||||||
|
from django.conf import settings
|
||||||
|
from django.conf.urls.static import static
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', admin.site.urls),
|
||||||
|
path('',views.home, name='home'),
|
||||||
|
path('accounts/',include('accounts.urls')),
|
||||||
|
path('products/',include('products.urls')),
|
||||||
|
|
||||||
|
]+ static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
|
||||||
|
|
||||||
|
|
||||||
16
heroine/wsgi.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
"""
|
||||||
|
WSGI config for heroine project.
|
||||||
|
|
||||||
|
It exposes the WSGI callable as a module-level variable named ``application``.
|
||||||
|
|
||||||
|
For more information on this file, see
|
||||||
|
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
from django.core.wsgi import get_wsgi_application
|
||||||
|
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'heroine.settings')
|
||||||
|
|
||||||
|
application = get_wsgi_application()
|
||||||
21
manage.py
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
"""Django's command-line utility for administrative tasks."""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'heroine.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()
|
||||||
BIN
media/images/Thumbs.db
Normal file
BIN
media/images/banaras.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_8LBnRQw.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_8zm3Cag.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_OkMsMyg.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_VfE53Mg.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_ZreUCSB.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_fHXNEIa.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_jnmetbX.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/banaras_qcPk65N.jpg
Normal file
|
After Width: | Height: | Size: 7.4 KiB |
BIN
media/images/carry.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
media/images/carry_nysnJy5.jpg
Normal file
|
After Width: | Height: | Size: 4.0 KiB |
BIN
media/images/carrybhai.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
media/images/carryminati.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
media/images/corona.jpg
Normal file
|
After Width: | Height: | Size: 10 KiB |
BIN
media/images/coronaicon.jpg
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
media/images/create1.jpg
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
media/images/create1_pUkv3CJ.jpg
Normal file
|
After Width: | Height: | Size: 3.2 KiB |
BIN
media/images/create2.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_5O4hyC5.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_9hgiphd.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_Bbsy5my.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_UM7C3Se.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_bT64gLA.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_oQhTCyR.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create2_r1DaO5D.png
Normal file
|
After Width: | Height: | Size: 2.0 KiB |
BIN
media/images/create3.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
media/images/create3_3tx6tXQ.png
Normal file
|
After Width: | Height: | Size: 5.2 KiB |
BIN
media/images/django.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
BIN
media/images/logo1.jpg
Normal file
|
After Width: | Height: | Size: 6.4 KiB |
BIN
media/images/mumbai.jpg
Normal file
|
After Width: | Height: | Size: 3.5 KiB |
BIN
media/images/music1.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
media/images/music1_FTVE53r.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
media/images/music1_QmsrQlV.jpg
Normal file
|
After Width: | Height: | Size: 59 KiB |
BIN
media/images/new4.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
media/images/new4_xP0QTTo.jpg
Normal file
|
After Width: | Height: | Size: 8.1 KiB |
BIN
media/images/rohit.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
media/images/rohit_yYWLObF.jpg
Normal file
|
After Width: | Height: | Size: 58 KiB |
BIN
media/images/rohiticon.jpg
Normal file
|
After Width: | Height: | Size: 5.1 KiB |
BIN
media/images/youtubelogo.jpg
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
BIN
media/images/youtubelogo_EPVggvE.jpg
Normal file
|
After Width: | Height: | Size: 4.5 KiB |
0
products/__init__.py
Normal file
BIN
products/__pycache__/__init__.cpython-37.pyc
Normal file
BIN
products/__pycache__/admin.cpython-37.pyc
Normal file
BIN
products/__pycache__/apps.cpython-37.pyc
Normal file
BIN
products/__pycache__/models.cpython-37.pyc
Normal file
BIN
products/__pycache__/urls.cpython-37.pyc
Normal file
BIN
products/__pycache__/views.cpython-37.pyc
Normal file
5
products/admin.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.contrib import admin
|
||||||
|
|
||||||
|
from .models import Product
|
||||||
|
|
||||||
|
admin.site.register(Product)
|
||||||
5
products/apps.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
from django.apps import AppConfig
|
||||||
|
|
||||||
|
|
||||||
|
class ProductsConfig(AppConfig):
|
||||||
|
name = 'products'
|
||||||
30
products/migrations/0001_initial.py
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Generated by Django 2.2 on 2020-05-19 11:08
|
||||||
|
|
||||||
|
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='Product',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('title', models.CharField(max_length=255)),
|
||||||
|
('pub_date', models.DateTimeField()),
|
||||||
|
('url', models.TextField()),
|
||||||
|
('image', models.ImageField(upload_to='')),
|
||||||
|
('icon', models.ImageField(upload_to='')),
|
||||||
|
('votes_total', models.IntegerField()),
|
||||||
|
('hunter', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
]
|
||||||
28
products/migrations/0002_auto_20200519_2214.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
# Generated by Django 2.2 on 2020-05-19 16:44
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='icon',
|
||||||
|
field=models.ImageField(upload_to='images/'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='image',
|
||||||
|
field=models.ImageField(upload_to='images/'),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='votes_total',
|
||||||
|
field=models.IntegerField(default=1),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
products/migrations/0003_product_body.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.2 on 2020-05-20 03:30
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0002_auto_20200519_2214'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='product',
|
||||||
|
name='body',
|
||||||
|
field=models.TextField(default=''),
|
||||||
|
),
|
||||||
|
]
|
||||||
18
products/migrations/0004_auto_20200520_0916.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 2.2 on 2020-05-20 03:46
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('products', '0003_product_body'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='product',
|
||||||
|
name='body',
|
||||||
|
field=models.TextField(max_length=300),
|
||||||
|
),
|
||||||
|
]
|
||||||
0
products/migrations/__init__.py
Normal file
BIN
products/migrations/__pycache__/0001_initial.cpython-37.pyc
Normal file
BIN
products/migrations/__pycache__/0003_product_body.cpython-37.pyc
Normal file
BIN
products/migrations/__pycache__/__init__.cpython-37.pyc
Normal file
25
products/models.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
from django.db import models
|
||||||
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
# Create your models here.
|
||||||
|
class Product(models.Model):
|
||||||
|
title= models.CharField(max_length=255)
|
||||||
|
pub_date=models.DateTimeField()
|
||||||
|
body=models.TextField(max_length=300)
|
||||||
|
url=models.TextField()
|
||||||
|
image=models.ImageField(upload_to='images/')
|
||||||
|
icon=models.ImageField(upload_to='images/')
|
||||||
|
votes_total=models.IntegerField(default=1)
|
||||||
|
hunter=models.ForeignKey(User,on_delete=models.CASCADE)
|
||||||
|
|
||||||
|
def _str_(self):
|
||||||
|
return self.title
|
||||||
|
|
||||||
|
def summary(self):
|
||||||
|
return self.body[:100]
|
||||||
|
|
||||||
|
def pub_date_pretty(self):
|
||||||
|
return self.pub_date.strftime('%b %e %Y')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
40
products/templates/create.html
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
|
||||||
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
{% if error %}
|
||||||
|
{{ error }}
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h1>Create</h1>
|
||||||
|
|
||||||
|
<form method="POST" action="{% url 'create' %}" enctype="multipart/form-data">
|
||||||
|
{% csrf_token %}
|
||||||
|
Title:
|
||||||
|
<br />
|
||||||
|
<input type="text" name="title" />
|
||||||
|
<br />
|
||||||
|
Body:
|
||||||
|
<br />
|
||||||
|
<input type="text" name="body" />
|
||||||
|
<br />
|
||||||
|
URL:
|
||||||
|
<br />
|
||||||
|
<input type="text" name="url" />
|
||||||
|
<br />
|
||||||
|
Icon:
|
||||||
|
<br />
|
||||||
|
<input type="file" name="icon" />
|
||||||
|
<br />
|
||||||
|
Image:
|
||||||
|
<br />
|
||||||
|
<input type="file" name="image" />
|
||||||
|
<br />
|
||||||
|
<br />
|
||||||
|
<input class="btn btn-primary" type="submit" value="Add Product" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
45
products/templates/detail.html
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{% extends 'base.html'%}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-2">
|
||||||
|
<img src="{{ product.icon.url }}" class="img-fluid"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-10">
|
||||||
|
<a href="{{ product.url }}"><h1>{{product.title}}</h1></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8">
|
||||||
|
<img src="{{ product.image.url }}" class="img-fluid"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-4">
|
||||||
|
<a href="javascript:{document.getElementById('upvote').submit()}"><button class="btn btn-primary btn-lg btn-block "><span class="oi oi-caret-top"></span>Upvote {{product.votes_total}}</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-4 ">
|
||||||
|
<h4>Hunted by {{ product.hunter.username }}</h4>
|
||||||
|
</div>
|
||||||
|
<div class="col-4 text-">
|
||||||
|
<h4><span class="oi oi-clock"></span> {{ product.pub_date_pretty }}</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-8 ">
|
||||||
|
<p>{{ product.body }}</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<form id="upvote" method="POST" action="{% url 'upvote' product.id %}" >
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
32
products/templates/home.html
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
{% extends 'base.html'%}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
|
||||||
|
|
||||||
|
{% for product in products.all %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row pt-3">
|
||||||
|
<div class="col-2" onclick="window.location='{% url 'detail' product.id %}';" style="cursor: pointer;">
|
||||||
|
<img src="{{ product.icon.url }}" class="img-fluid"/>
|
||||||
|
</div>
|
||||||
|
<div class="col-6 onclick="window.location='{% url 'detail' product.id %}';" style="cursor: pointer;"">
|
||||||
|
<h1>{{product.title}}</h1>
|
||||||
|
<p>{{product.summary}}</p>
|
||||||
|
</div>
|
||||||
|
<div class="col-4 onclick="window.location='{% url 'detail' product.id %}';" style="cursor: pointer;"">
|
||||||
|
<a href="javascript:{document.getElementById('upvote{{product.id}}').submit()}"><button class="btn btn-primary btn-lg btn-block "><span class="oi oi-caret-top"></span>Upvote {{product.votes_total}}</button></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<form id="upvote{{product.id}}" method="POST" action="{% url 'upvote' product.id %}" >
|
||||||
|
{% csrf_token %}
|
||||||
|
<input type="hidden">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
3
products/tests.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
from django.test import TestCase
|
||||||
|
|
||||||
|
# Create your tests here.
|
||||||
8
products/urls.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
from django.urls import path
|
||||||
|
from . import views
|
||||||
|
|
||||||
|
urlpatterns=[
|
||||||
|
path('create',views.create, name='create'),
|
||||||
|
path('<int:product_id>/',views.detail, name='detail'),
|
||||||
|
path('<int:product_id>/upvote',views.upvote, name='upvote'),
|
||||||
|
]
|
||||||