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

update to public #8

Merged
merged 12 commits into from
Sep 24, 2024
Merged
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
16 changes: 8 additions & 8 deletions .github/workflows/deploy_toserver_production.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Deploy to server production
on: [workflow_dispatch]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: build-apps
Expand All @@ -13,11 +17,7 @@ jobs:
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /opt/GPMain
cd $HOME/Projek/geraipi_main
source $HOME/virtualenv/Projek/geraipi_main/3.10/bin/activate
git pull origin main
export $(grep -v '^#' .env | xargs)
/opt/geraienv/bin/python /opt/GPMain/manage.py makemigrations
/opt/geraienv/bin/python /opt/GPMain/manage.py migrate
echo yes | /opt/geraienv/bin/python /opt/GPMain/manage.py collectstatic
service uwsgi restart
service nginx restart
touch tmp/restart.txt
18 changes: 9 additions & 9 deletions .github/workflows/deploy_toserver_test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: Deploy to server test
on: [workflow_dispatch]
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: build-apps
Expand All @@ -13,11 +17,7 @@ jobs:
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /opt/geraipi
git pull origin2 main
export $(grep -v '^#' .env | xargs)
/opt/geraienv/bin/python /opt/geraipi/manage.py makemigrations
/opt/geraienv/bin/python /opt/geraipi/manage.py migrate
echo yes | /opt/geraienv/bin/python /opt/geraipi/manage.py collectstatic
service uwsgi restart
service nginx restart
cd $HOME/Projek/geraipi_test
source $HOME/virtualenv/Projek/geraipi_test/3.10/bin/activate
git pull origin main
touch tmp/restart.txt
29 changes: 27 additions & 2 deletions frontend/templates/firebase-messaging-sw.js

Large diffs are not rendered by default.

26 changes: 12 additions & 14 deletions frontend/templates/layout.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{% load static tailwind_tags %}
{% load i18n translater %}
<!DOCTYPE html>
{% load static tailwind_tags i18n translater %}
<html data-theme="bumblebee" lang="en">
<head>
<meta charset="UTF-8" />
Expand Down Expand Up @@ -221,31 +220,31 @@
</script> -->
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-app.js'

// If you enabled Analytics in your project, add the Firebase SDK for Google Analytics
import { getAnalytics } from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-analytics.js'

import {getMessaging, getToken} from 'https://www.gstatic.com/firebasejs/10.7.1/firebase-messaging.js'

// Your web app's Firebase configuration
// For Firebase JS SDK v7.20.0 and later, measurementId is optional
const permission = await Notification.requestPermission();
const firebaseConfig = {
apiKey: "AIzaSyCsEEl7bhST8VHrK3ovbEfMxCUcHZngKg0",
authDomain: "geraipi.firebaseapp.com",
projectId: "geraipi",
storageBucket: "geraipi.appspot.com",
messagingSenderId: "1071852496864",
appId: "1:1071852496864:web:c5e8338dc67fa12d9bad85",
measurementId: "G-SW3CZ09N71"
apiKey: "AIzaSyC0lUXHwQdTFXz8KkC5D7zy-t47RrkIvsY",
authDomain: "geraipi-indonesia.firebaseapp.com",
projectId: "geraipi-indonesia",
storageBucket: "geraipi-indonesia.appspot.com",
messagingSenderId: "981139646267",
appId: "1:981139646267:web:53cc230affb50210a5391e",
measurementId: "G-F368X3MB4J"
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);
const messaging = getMessaging(app);
// Add the public key generated from the console here.
let token = await getToken(messaging, {vapidKey: "BFN7KQFtuiq9l_tkSE3GcS66hqmsG7ddDjL5wrpSlegQY5_YGzp1LD5F3vn74RP4skldx5A_7k9DQuswI5zYUEs"})
let token = await getToken(messaging, {vapidKey: "BFNEyQSIq15u8X4bGCqLOtU_CLe3RzF_eZ5Vx5mPA0UKqeMNi3GCJTGuMquBuc2CpIxvsTKD3Xb-twq2CnFzNyA"})
if(token){
{% if user.is_authenticated %}
console.log("token", token)
$.ajax({
url: '{% url "fcm_token" %}',
method: "post",
Expand All @@ -254,13 +253,12 @@
console.log("success")
}
})
{% endif %}

}else{

}
</script>
<script>
</script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
<script type="text/javascript" src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>
<script>
Expand Down
22 changes: 19 additions & 3 deletions frontend/templates/profil/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ <h6 class="font-bold">{% translater user.languages.code "profile_setting_title"
<a href="/profile/alamat" class="no-underline p-2 hover:bg-slate-200 rounded color-black bg-slate-100">{% translater user.languages.code "profile_menu_alamat_saya" "Alamat Saya" %}</a>
<a href="{% url 'transaksi_users' %}" class="no-underline p-2 rounded color-black bg-slate-100 hover:bg-slate-200">{% translater user.languages.code "profile_menu_transaksi_saya" "Transaksi" %}</a>
<a href="/faq/" class="no-underline p-2 rounded color-black bg-slate-100 hover:bg-slate-200">FAQ</a>
<input type="text" value="{{ url_data }}" id="copinput" style="display: none;">
<!-- <a href="javascript:void(0)" class="no-underline p-2 rounded color-black bg-slate-100 hover:bg-slate-200" onclick="myFunction()">Copy to Chrome</a> -->
{% if registered %}
{% else %}
<a href="/member/" class="no-underline p-2 rounded color-black bg-slate-100 hover:bg-slate-200">Register Membership</a>
Expand All @@ -89,8 +91,8 @@ <h6 class="font-bold">{% translater user.languages.code "toko_title_setting" "Se
</div>
{% else %}
<div class="flex flex-col justify-center gap-6">
<span class="bg-red-400/20 text-red-800 text-sm p-2 font-light">Anda belum login silahkan Login terlebih Dahulu</span>
<button id="loginn" class="bg-orange-400 text-white py-3 rounded-full" onclick="redirect_nologin()">Login</button>
<span class="bg-red-400/20 text-red-800 text-sm p-2 font-light">Silahkan buka pibrowser untuk lo</span>
<button id="loginn" class="bg-orange-400 text-white py-3 rounded-full" onclick="redirect_nologin()">Goto PiBrowser</button>
</div>
{% endif %}
</div>
Expand All @@ -107,9 +109,23 @@ <h6 class="font-bold">{% translater user.languages.code "toko_title_setting" "Se
})

function redirect_nologin(){

window.open("pi://geraipi.id")
}

function myFunction() {
// Get the text field
var copyText = document.getElementById("copinput");

// Select the text field
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices

// Copy the text inside the text field
navigator.clipboard.writeText(copyText.value);

// Alert the copied text
alert("Copied the text: " + copyText.value);
}


{% comment %}
Expand Down
11 changes: 10 additions & 1 deletion frontend/templates/profil/transaksi_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,16 @@
</div>
<div class="p-2 break-words">
<h3 class="text-[20px] font-bold">{{ tr.produk.nama }}</h3>
<p class="text-[12px]">Tanggal diambil: {{ tr.cart.tanggal }}</p>
{% if tr.cart.status == 1 %}
<p class="text-[12px]">
Tanggal order: {{ tr.cart.tanggal }}
</p>
{% endif %}
{% if tr.cart.status >= 3 %}
<p class="text-[12px]">
Tanggal dikirim: {{ tr.cart.tanggal_dikirim }}
</p>
{% endif %}
<p class="text-[13px]">{{ tr.produk.harga }} Pi</p>
<p class="text-[12px] break-all">{% if tr.cart.catatan %} {{ tr.cart.catatan | truncatewords:5 }} {% else %} - {% endif %} </p>
</div>
Expand Down
File renamed without changes.
40 changes: 36 additions & 4 deletions frontend/templates/toko/listtransaksi.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,21 @@
</div>
<div class="p-2 break-words">
<h3 class="text-sm font-bold">{{ tr.produk.nama }}</h3>
<p class="text-[10px]">Tanggal diambil: {{ tr.cart.tanggal }}</p>
{% if tr.cart.status == 1 %}
<p class="text-[10px]">
Tanggal order: {{ tr.cart.tanggal }}
</p>
{% endif %}
{% if tr.cart.status == 3 %}
<p class="text-[10px]">
Tanggal dikirim: {{ tr.cart.tanggal_dikirim }}
</p>
{% endif %}
{% if tr.cart.status > 3 %}
<p class="text-[10px]">
Tanggal dikirim: {{ tr.cart.tanggal_selesai }}
</p>
{% endif %}
<p class="text-[13px]">{{ tr.produk.harga }} Pi</p>
<p class="text-[12px] break-all">{% if tr.cart.catatan %} {{ tr.cart.catatan | truncatewords:5 }} {% else %} - {% endif %}</p>
</div>
Expand Down Expand Up @@ -84,10 +98,20 @@ <h3 class="text-lg font-bold text-center">Detail Barang ({{ tr.cart.kode }})</h3
<td><p class="text-[12px]">{{ tr.produk.nama }}</p></td>
</tr>
<tr>
<td class="w-[110px] align-top"><p class="text-[12px]">Tanggal diambil: </p></td>
<td class="w-[110px] align-top"><p class="text-[12px]">Tanggal order: </p></td>
<td class="w-[1px] align-top">:</td>
<td><p class="text-[12px]">{{ tr.cart.tanggal | date:'d M Y' }}</p></td>
</tr>
<tr></tr>
<td class="w-[110px] align-top"><p class="text-[12px]">Tanggal dikirim: </p></td>
<td class="w-[1px] align-top">:</td>
<td><p class="text-[12px]">{{ tr.cart.tanggal_dikirim | date:'d M Y' }}</p></td>
</tr>
<tr></tr>
<td class="w-[110px] align-top"><p class="text-[12px]">Tanggal selesai: </p></td>
<td class="w-[1px] align-top">:</td>
<td><p class="text-[12px]">{{ tr.cart.tanggal_selesai | date:'d M Y' }}</p></td>
</tr>
{% for t in tr.user_chart.addressuserchartitem_set.all %}
<tr>
<td class="w-[110px] align-top"><p class="font-bold text-[12px]">Alamat Pembeli:</p></td>
Expand Down Expand Up @@ -140,7 +164,7 @@ <h3 class="text-lg font-bold text-center">Detail Barang ({{ tr.cart.kode }})</h3
<label for="">{{transaksi.cart.expedisi}}</label>
{% endif %}
{% if tr.cart.status_toko == 2 %}
<form method="post" class="flex flex-row gap-2 py-4" id="transaksi">
<form method="post" class="flex flex-row gap-2 py-4" id="transaksi-{{tr.cart.id}}">
<input type="hidden" value="{{ tr.cart.id }}" name="cart_id" class="rounded-full"/>

<select id="expedisi" class="bg-slate-50 border border-slate-300 text-slate-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block p-1 w-full" required>
Expand All @@ -153,7 +177,7 @@ <h3 class="text-lg font-bold text-center">Detail Barang ({{ tr.cart.kode }})</h3
<input type="text" placeholder="Type here" class="input input-bordered input-primary w-full max-w-xs h-[2rem] max-h-[2rem]" value="{% if tr.cart.nomor_resi %}{{ tr.cart.nomor_resi }}{% endif %}" name="nomor_resi" />

<input type="hidden" value="" name="expedisi" required/>
<button type="submit" class="btn btn-warning btn-sm">Send</button>

</form>
{% endif %}
</div>
Expand All @@ -167,6 +191,11 @@ <h3 class="text-lg font-bold text-center">Detail Barang ({{ tr.cart.kode }})</h3
{% endif %}

<form method="dialog">
{% if tr.cart.status_toko == 2 %}
<button class="btn btn-sm btn-success" type="button" onclick="sendKurir('transaksi-{{tr.cart.id}}')">Kirim</button>
{% elif tr.cart.status_toko == 3 %}
<a class="btn btn-sm btn-success" href="#">Laporkan</a>
{% endif %}
<!-- if there is a button in form, it will close the modal -->
<button class="btn btn-sm" type="submit">Close</button>
</form>
Expand All @@ -181,6 +210,9 @@ <h3 class="text-lg font-bold text-center">Detail Barang ({{ tr.cart.kode }})</h3
{% endblock %}
{% block script %}
<script>
async function sendKurir(id){
$(`#${id}`).submit()
}
function show_modals(ids) {
document.getElementById(ids).showModal();
}
Expand Down
6 changes: 6 additions & 0 deletions frontend/templatetags/translater.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import Any

from django import template

Expand All @@ -17,3 +18,8 @@ def translater(to, page, value):
@register.filter
def env(key):
return os.environ.get(key, False)


@register.filter(name="length_is")
def length_is(value: Any, length: str | int) -> bool:
return len(value) == int(length)
32 changes: 22 additions & 10 deletions frontend/urls.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
from django.urls import path

# One Login
from sesame.views import LoginView

from frontend.views.aboutapp_view import AboutApp
from frontend.views.add_to_cart_view import AddToCart
from frontend.views.alamat_toko_delete_view import DeleteAlamatToko
from frontend.views.alamat_toko_view import AlamatToko
from frontend.views.alamt_toko_tambah_view import AlamatTokoTambah
from frontend.views.approve_view import Approve
from frontend.views.archive_barang_view import ArchiveBarang
from frontend.views.beli_view import Beli
from frontend.views.beranda.home import Home
from frontend.views.cancel_view import Cancel
from frontend.views.cart_json_view import CartJson

# Checkout
from frontend.views.cart.add_to_cart_view import AddToCart
from frontend.views.cart.approve_view import Approve
from frontend.views.cart.cart_json_view import CartJson
from frontend.views.cart.toko_transaksi_view import TransaksiToko
from frontend.views.completepayment_view import CompletePayment
from frontend.views.coreteam_view import CoreTeam
from frontend.views.detail_transaksi_json_view import DetailTransaksiJson
Expand All @@ -21,7 +23,6 @@
from frontend.views.faq_view import Faq
from frontend.views.fcm_save_token import FcmSaveTokenView
from frontend.views.getdata_view import GetData
from frontend.views.jual_view import Jual
from frontend.views.keranjang_add_view import KeranjangAdd
from frontend.views.koleksi_view import Koleksi
from frontend.views.list_produk_toko_view import ListProdukToko
Expand All @@ -35,6 +36,8 @@

# produk
from frontend.views.produk.produk_view import Produks

# User
from frontend.views.profile.alamat_user_view import AlamatUser
from frontend.views.profile.profile_alamat_view import ProfileAlamat
from frontend.views.profile.profile_edit_view import ProfileEdit
Expand All @@ -49,12 +52,20 @@
from frontend.views.service_worker import ServiceWorkerView
from frontend.views.setcomplete_view import SetComplete
from frontend.views.settings_view import Settings
from frontend.views.splash import Splash

# Splash
from frontend.views.splash.splash import Splash
from frontend.views.tentang_view import Tentang
from frontend.views.termofservice_view import TermOfService
from frontend.views.toko.alamat_toko_delete_view import DeleteAlamatToko
from frontend.views.toko.alamat_toko_view import AlamatToko
from frontend.views.toko.alamt_toko_tambah_view import AlamatTokoTambah
from frontend.views.toko.archive_barang_view import ArchiveBarang

# toko
from frontend.views.toko.jual_view import Jual
from frontend.views.toko.toko_view import Toko
from frontend.views.toko_edit_view import TokoEdit
from frontend.views.toko_transaksi_view import TransaksiToko
from frontend.views.transaksi_selesai_view import TransaksiUserSelesaiJson
from frontend.views.transaksi_user_count_json_view import TransaksiUserCountJson
from frontend.views.transaksi_user_json_view import TransaksiUserJson
Expand Down Expand Up @@ -202,4 +213,5 @@
),
path("fcm-token", FcmSaveTokenView.as_view(), name="fcm_token"),
path("validation-key.txt", VerificationCode.as_view(), name="verification"),
path("sess/login", LoginView.as_view(), name="log_less"),
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt

from frontend.views.base_view import FrontPage
from produk.models import Cart, CartItem, Produk

from .base_view import FrontPage


@method_decorator(csrf_exempt, name="dispatch")
@method_decorator(login_required(login_url="/profile"), name="dispatch")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.utils.decorators import method_decorator
from django.views.decorators.csrf import csrf_exempt

from frontend.views.base_view import FrontPage
from produk.models import (
AddressUserChartItem,
Cart,
Expand All @@ -18,8 +19,6 @@
from profiles.models import UserProfileAddress
from store.models import UserStore

from .base_view import FrontPage


@method_decorator(csrf_exempt, name="dispatch")
@method_decorator(login_required(login_url="/profile"), name="dispatch")
Expand Down
Loading
Loading