Skip to content

Commit

Permalink
Merge pull request #7 from roniahmadi/main
Browse files Browse the repository at this point in the history
update and add uv
  • Loading branch information
roniahmadi authored Sep 16, 2024
2 parents 0e55702 + 137a4a5 commit e87f979
Show file tree
Hide file tree
Showing 195 changed files with 461,733 additions and 4,654 deletions.
File renamed without changes.
12 changes: 12 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
SECRET_KEY={SECRET_KEY}
DB_HOST={DB_HOST}
DB_NAME={DB_NAME}
DB_USER={DB_USER}
DB_PASSWORD={DB_PASSWORD}

EMAIL_HOST={EMAIL_HOST}
EMAIL_PORT={EMAIL_PORT}
EMAIL_HOST_USER={EMAIL_HOST_USER}
EMAIL_HOST_PASSWORD={EMAIL_HOST_PASSWORD}

NPM_ENV={NPM_ENV}
3 changes: 2 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ exclude =
manage.py
settings.py
env
.env
.env
.venv
23 changes: 23 additions & 0 deletions .github/workflows/deploy_toserver_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to server production
on: [workflow_dispatch]
jobs:
build:
name: build-apps
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
script: |
cd /opt/GPMain
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
23 changes: 23 additions & 0 deletions .github/workflows/deploy_toserver_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy to server test
on: [workflow_dispatch]
jobs:
build:
name: build-apps
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ mysql
.env
**/__pycache__
**/migrations
# projekpi/settings.py #
projekpi/settings.py
media
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.10
12 changes: 11 additions & 1 deletion apidata/serializers/produks_serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

from .stores_serializer import UserStoreSerializer

# from rest_framework.response import Response
# from .ulasan_serializer import UlasanSerializer


class KategoriSerializer(serializers.HyperlinkedModelSerializer):
nama = serializers.SerializerMethodField()
Expand Down Expand Up @@ -97,6 +100,7 @@ class ProdukSerializer(serializers.HyperlinkedModelSerializer):
gambar = serializers.SerializerMethodField()
count_star = serializers.SerializerMethodField()
produk_detail_url = serializers.SerializerMethodField()
terjual = serializers.SerializerMethodField()

nama = serializers.SerializerMethodField()

Expand All @@ -122,6 +126,7 @@ class Meta:
"store",
"count_star",
"produk_detail_url",
"terjual",
]

def get_nama(self, obj):
Expand All @@ -147,7 +152,7 @@ def get_count_star(self, obj):
return countstar

def get_produk_detail_url(self, obj):
urldetail = reverse("detail_produk", kwargs={"slug": obj.slug})
urldetail = reverse("produk_detail", kwargs={"slug": obj.slug})
return urldetail

def get_gambar(self, obj):
Expand All @@ -161,3 +166,8 @@ def get_store(self, obj):
if stores.exists():
stores = stores.first()
return UserStoreSerializer(stores).data

def get_terjual(self, obj):
terjual = 0
terjual = UlasanCart.objects.filter(produkitem_id=obj.id).count()
return terjual
2 changes: 1 addition & 1 deletion apidata/viewsets/produks_viewset.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ProdukViewSet(viewsets.ModelViewSet):
"""

filter_backends = [DjangoFilterBackend]
filterset_fields = ["kategori", "negara"]
filterset_fields = ["kategori", "negara", "slug"]
queryset = Produk.objects.all()
serializer_class = ProdukSerializer
http_method_names = ["get", "head", "option"]
Expand Down
33 changes: 33 additions & 0 deletions assets/js/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { initializeApp } from "firebase/app";
import { getMessaging, getToken } from "firebase/messaging";

// TODO: Replace the following with your app's Firebase project configuration
// See: https://firebase.google.com/docs/web/learn-more#config-object
const firebaseConfig = {
apiKey: "AIzaSyCsEEl7bhST8VHrK3ovbEfMxCUcHZngKg0",
authDomain: "geraipi.firebaseapp.com",
projectId: "geraipi",
storageBucket: "geraipi.appspot.com",
messagingSenderId: "1071852496864",
appId: "1:1071852496864:web:c5e8338dc67fa12d9bad85",
measurementId: "G-SW3CZ09N71"
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);


// Initialize Firebase Cloud Messaging and get a reference to the service
const messaging = getMessaging(app);
getToken(messaging, { vapidKey: 'BFN7KQFtuiq9l_tkSE3GcS66hqmsG7ddDjL5wrpSlegQY5_YGzp1LD5F3vn74RP4skldx5A_7k9DQuswI5zYUEs' }).then((currentToken) => {
if (currentToken) {
// Send the token to your server and update the UI if necessary
// ...
console.log("token")
} else {
console.log('No registration token available. Request permission to generate one.');
}
}).catch((err) => {
console.log('An error occurred while retrieving token. ', err);
// ...
});
28 changes: 28 additions & 0 deletions assets/js/other.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { initializeApp } from "firebase/app";
import { getMessaging } from "firebase/messaging/sw";
import { onBackgroundMessage } from "firebase/messaging/sw";

const firebaseConfig = {
apiKey: "AIzaSyCsEEl7bhST8VHrK3ovbEfMxCUcHZngKg0",
authDomain: "geraipi.firebaseapp.com",
projectId: "geraipi",
storageBucket: "geraipi.appspot.com",
messagingSenderId: "1071852496864",
appId: "1:1071852496864:web:c5e8338dc67fa12d9bad85",
measurementId: "G-SW3CZ09N71"
};

const app = initializeApp(firebaseConfig);

const messaging = getMessaging(app);
onBackgroundMessage(messaging, (payload) => {
console.log('[firebase-messaging-sw.js] Received background message ', payload);
// Customize notification here
const notificationTitle = 'Background Message Title';
const notificationOptions = {
body: 'Background Message body.',
icon: '/firebase-logo.png'
};

self.registration.showNotification(notificationTitle, notificationOptions);
});
5 changes: 5 additions & 0 deletions bable.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

module.exports = {
presets: ['@babel/preset-env', '@babel/preset-react'],
};
1 change: 1 addition & 0 deletions data/data/banner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"model": "frontend.banner", "pk": 1, "fields": {"name": "Image01", "image": "image_banner/Banner01_TdjEAEI.jpg"}}, {"model": "frontend.banner", "pk": 2, "fields": {"name": "Image2", "image": "image_banner/Banner2_VQNjzOj.jpg"}}]
Loading

0 comments on commit e87f979

Please sign in to comment.