Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pay with paypal button #36

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ static/
__pycache__/
env/
node_modules/
themes/
demo/
6 changes: 6 additions & 0 deletions assets/src/app/app.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ <h4 class="mb-5">
</div>

</div>
<div class="d-flex align-items-left justify-content-between">
<div class="form-check">
<a href="{{forgetPasswordUrl}}">Forget password?</a>
</div>
</div>

<div class="d-flex align-items-center justify-content-between">
<div class="form-check">
<input type="checkbox" [checked]="rememberMe" (change)="rememberMe = !rememberMe" name="" class="form-check-input" id="rememberUser">
Expand Down
2 changes: 2 additions & 0 deletions assets/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class AppComponent implements OnInit {
usersForm;
errors;
rememberMe:boolean = false;
domain_url = '192.168.2.30';
forgetPasswordUrl = "http://"+this.domain_url+":8000/user/password_reset/";

constructor(
private authService: AuthService,
Expand Down
7 changes: 4 additions & 3 deletions assets/src/app/commons/services/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ export class AuthService {
rememberMe:boolean;
token;
user;
domain_url = '192.168.2.30';
constructor(private http: HttpClient) { }

// Generate token upon login
loginAuth(user,remember){
this.rememberMe = remember;
this.user = user;
return this.http.post<any>("http://localhost:8000/user/login/", user)
return this.http.post<any>("http://"+this.domain_url+":8000/user/login/", user)
.toPromise()
.then(
response => {
Expand All @@ -31,7 +32,7 @@ export class AuthService {

// Generate token upon register
registerAuth(user){
return this.http.post<any>("http://localhost:8000/user/register/", user)
return this.http.post<any>("http://"+this.domain_url+"/user/register/", user)
.toPromise()
.then(
response => {
Expand All @@ -44,7 +45,7 @@ export class AuthService {
}

refreshToken(user){
return this.http.get<any>("http://localhost:8000/user/refresh/", user)
return this.http.get<any>("http://"+this.domain_url+"localhost:8000/user/refresh/", user)
.toPromise()
.then(
response => {
Expand Down
20 changes: 19 additions & 1 deletion assets/src/app/commons/services/cart/cart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
export class CartService {

httpHeaders = new HttpHeaders({'Content-type':'application/json'});
domain_url = '192.168.2.30';

constructor(
private http: HttpClient) { }

getThemeCart(id){
return this.http.get<any>('http://localhost:8000/home/theme/cart/'+id+'/', {headers: this.httpHeaders})
return this.http.get<any>('http://'+this.domain_url+':8000/home/theme/cart/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand All @@ -24,4 +26,20 @@ export class CartService {
}
)
}

buyThemeService(id){
return this.http.get<any>('http://'+this.domain_url+':8000/details/download/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)

}
}
5 changes: 3 additions & 2 deletions assets/src/app/commons/services/details/details.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import { HttpClient, HttpHeaders } from '@angular/common/http';
})
export class DetailsService {

domain_url = '192.168.2.30';
httpHeaders = new HttpHeaders({'Content-type': 'application/json'});
constructor(
private http: HttpClient) { }

getThemeDetailsService(id){
return this.http.get<any>('http://localhost:8000/home/theme/details/'+id+'/', {headers: this.httpHeaders})
return this.http.get<any>('http://'+this.domain_url+':8000/home/theme/details/'+id+'/', {headers: this.httpHeaders})
.toPromise()
.then(
response =>{
Expand All @@ -26,7 +27,7 @@ export class DetailsService {
}

createReviewService(comment){
return this.http.post<any>("http://localhost:8000/details/createReview/",comment)
return this.http.post<any>("http://"+this.domain_url+":8000/details/createReview/",comment)
.toPromise()
.then(
response => {
Expand Down
5 changes: 3 additions & 2 deletions assets/src/app/commons/services/home/home.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ import { Observable } from 'rxjs';
})
export class HomeService {

domain_url = '192.168.2.30';
httpHeaders = new HttpHeaders({'Content-type': 'application/json'});
public categories;
constructor(private http: HttpClient) {
this.categories = this.getCategory();
}

getThemes(){
return this.http.get<any>("http://localhost:8000/home/theme/", {headers: this.httpHeaders})
return this.http.get<any>("http://"+this.domain_url+":8000/home/theme/", {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand All @@ -29,7 +30,7 @@ export class HomeService {
}

getCategory(){
return this.http.get<any>("http://localhost:8000/home/theme/category/", {headers: this.httpHeaders})
return this.http.get<any>("http://"+this.domain_url+":8000/home/theme/category/", {headers: this.httpHeaders})
.toPromise()
.then(
response => {
Expand Down
14 changes: 8 additions & 6 deletions assets/src/app/components/cart/cart.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<section class="mb-5">
<div class="row align-items-start">
<div class="col-md-6">
<img src="http://localhost:8000{{ theme.thumbnail.thumbnail }}" class="img-fluid" data-rjs="3">
<img src="http://{{ domain_url }}:8000{{ theme.thumbnail.thumbnail }}" class="img-fluid" data-rjs="3">
</div>
<div class="col-md-4 offset-md-1">
<div class="product-details">
Expand All @@ -28,12 +28,14 @@ <h3 class="mb-0">${{ theme.price }}</h3>
</div>
</div>
<p>Payment:</p>
<div class="d-flex payment-option">
<div class="d-flex payment-option" (click)="buyTheme($event,theme.id)">
<img src="assets/images/paypal-logo.jpg" class="mr-3" data-rjs="3">
<button class="btn btn-primary form-control ">
<span class="mr-3">Pay with PayPal</span>
<span class="icon ion-ios-arrow-thin-right"></span>
</button>
<a href="http://{{domain_url}}:8000{{ theme.file }}">
<button class="btn btn-primary form-control">
<span class="mr-3">Pay with PayPal</span>
<span class="icon ion-ios-arrow-thin-right"></span>
</button>
</a>
</div>
</div>
</div>
Expand Down
16 changes: 16 additions & 0 deletions assets/src/app/components/cart/cart.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class CartComponent implements OnInit {
theme;
discount;
dis_price;
domain_url = '192.168.2.30';
constructor(
private cartService: CartService,
private route: ActivatedRoute,
Expand Down Expand Up @@ -51,6 +52,21 @@ export class CartComponent implements OnInit {
)
}

buyTheme(event,theme_id){
console.log('clicked');
this.cartService.buyThemeService(theme_id)
.then(
response => {
return response;
}
)
.catch(
error => {
return error;
}
)
}



}
4 changes: 2 additions & 2 deletions assets/src/app/components/details/details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ <h5 class="section-title text-primary mb-1">{{ theme.name }}</h5>
<section class="mb-5">
<div class="row align-items-start">
<div class="col-md-6">
<img src="http://localhost:8000{{theme.thumbnail.thumbnail}}" class="img-fluid" data-rjs="3">
<img src="http://{{domain_url}}:8000{{theme.thumbnail.thumbnail}}" class="img-fluid" data-rjs="3">
</div>
<div class="col-md-4 offset-md-1">
<div class="product-details">
Expand Down Expand Up @@ -108,7 +108,7 @@ <h2 >{{ theme.name }}</h2>
<div class="col-md-6">
<h3 class="section-title">Screenshots</h3>
<ng-container *ngFor="let screenshots of theme.screenshot.screenshot">
<img src="http://localhost:8000/media/{{ screenshots.image }}/" data-rjs="3" class="img-fluid">
<img src="http://{{domain_url}}:8000/media/{{ screenshots.image }}/" data-rjs="3" class="img-fluid">
</ng-container>
</div>
<div class="col-md-6">
Expand Down
1 change: 1 addition & 0 deletions assets/src/app/components/details/details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class DetailsComponent implements OnInit {
reviews;
content;
token;
domain_url = '192.168.2.30';

constructor(
private route: ActivatedRoute,
Expand Down
3 changes: 2 additions & 1 deletion assets/src/app/components/home/home.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ export class HomeComponent implements OnInit {
themes;
category;
searchCategory;
baseUrl = "http://localhost:8000/media/";
domain_url = '192.168.2.30';
baseUrl = "http://"+this.domain_url+":8000/media/";


constructor(
Expand Down
1 change: 1 addition & 0 deletions details/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@

urlpatterns = [
path('createReview/', views.CreateReview.as_view()),
path('download/<int:theme_id>/',views.DownloadTheme.as_view()),
]
18 changes: 18 additions & 0 deletions details/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
from rest_framework.response import Response
from .serializers import ReviewSerializer
from rest_framework.authtoken.models import Token
from django.views.generic import View
from io import StringIO
from zipfile import ZipFile
from django.conf import settings
import os



Expand Down Expand Up @@ -53,6 +58,19 @@ def get_average_rating(self,list_values,key):
return self.sum_values/len(list_values)


class DownloadTheme(APIView):
"""download theme view
"""
permission_classes = (AllowAny,)

def get(self,*args,**kwargs):
theme = Theme.objects.get(id=kwargs.get('theme_id'))
file = str(theme.file)
file.replace(" ","%20")
return Response({'download': file})






Expand Down
4 changes: 3 additions & 1 deletion market/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []
ALLOWED_HOSTS = ["*"]


# Application definition
Expand Down Expand Up @@ -159,6 +159,8 @@
os.path.join(BASE_DIR, 'assets/'),
]

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

# Allow any settings to be defined in local_settings.py which should be
# ignored in your version control system allowing for settings to be
# defined per machine.
Expand Down
52 changes: 52 additions & 0 deletions templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{% load static %}

<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- PLUG INS -->
<link rel="stylesheet" type="text/css" href="{% static 'node_modules/select2/dist/css/select2.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'node_modules/animate.css/animate.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'node_modules/ionicons/css/ionicons.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'node_modules/bootstrap/dist/css/bootstrap-reboot.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'node_modules/bootstrap/dist/css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'src/styles.css' %}">
<!-- PLUG INS -->

<title>
{% block title %}
Marketplace
{% endblock title %}
</title>
</head>
<body >
<nav class="navbar navbar-expand-lg main-nav">
<div class="container">
<a href="http://localhost:4200/" class="navbar-brand">
<img src="{% static 'src/assets/images/logo.svg' %}" class="logo">
</a>
<ul class="ml-auto nav">
<li class="nav-item">
<a href="" class="nav-link">Swiftkind</a>
</li>
</ul>
</div>
</nav>
<main>
{% block content %}

{% endblock content %}
</main>
<script type="text/javascript" src="{% static 'node_modules/jquery/dist/jquery.min.js' %}"></script>
<script type="text/javascript" src="{% static 'node_modules/popper.js/dist/umd/popper.min.js' %}"></script>
<script type="text/javascript" src="{% static 'node_modules/bootstrap/dist/js/bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'node_modules/select2/dist/js/select2.min.js' %}"></script>
<script type="text/javascript" src="{% static 'node_modules/retinajs/dist/retina.min.js' %}"></script>
<script type="text/javascript" src="{% static 'node_modules/wowjs/dist/wow.min.js' %}"></script>

<script type="text/javascript" src="{% static 'js/main.js' %}"></script>
</body>
</html>
13 changes: 13 additions & 0 deletions templates/registration/password_reset_complete.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% load il8n %}

{% block content %}
<div class="container py-5">
<div class="text-center py-5">
<h2 class="section-title text-highlight mb-2">Forget your password?</h2>
<h4 class="mb-5">
{% trans "Your password has been set. Return to homepage to log " %}
</h4>
</div>
</div>
{% endblock content %}
Loading