diff --git a/Budget_Project/Budget_Application/static/core/images/background.jpg b/Budget_Project/Budget_Application/static/core/images/background.jpg
new file mode 100644
index 0000000..4eaebe8
Binary files /dev/null and b/Budget_Project/Budget_Application/static/core/images/background.jpg differ
diff --git a/Budget_Project/Budget_Application/templates/core/add_expense.html b/Budget_Project/Budget_Application/templates/core/add_expense.html
new file mode 100644
index 0000000..4c16a6c
--- /dev/null
+++ b/Budget_Project/Budget_Application/templates/core/add_expense.html
@@ -0,0 +1,17 @@
+{% extends "core/base.html" %}
+{% block content %}
+
Dodaj wydatek
+
+← Powrót
+{% endblock %}
diff --git a/Budget_Project/Budget_Application/templates/core/add_income.html b/Budget_Project/Budget_Application/templates/core/add_income.html
new file mode 100644
index 0000000..f3622f2
--- /dev/null
+++ b/Budget_Project/Budget_Application/templates/core/add_income.html
@@ -0,0 +1,17 @@
+{% extends "core/base.html" %}
+{% block content %}
+Dodaj przychód
+
+← Powrót
+{% endblock %}
diff --git a/Budget_Project/Budget_Application/templates/core/base.html b/Budget_Project/Budget_Application/templates/core/base.html
new file mode 100644
index 0000000..7379fd1
--- /dev/null
+++ b/Budget_Project/Budget_Application/templates/core/base.html
@@ -0,0 +1,14 @@
+
+
+
+
+ Budżet Domowy
+
+
+
+
+ {% block content %}
+ {% endblock %}
+
+
+
\ No newline at end of file
diff --git a/Budget_Project/Budget_Application/templates/core/currency_converter.html b/Budget_Project/Budget_Application/templates/core/currency_converter.html
new file mode 100644
index 0000000..67888d9
--- /dev/null
+++ b/Budget_Project/Budget_Application/templates/core/currency_converter.html
@@ -0,0 +1,55 @@
+{% extends 'core/base.html' %}
+
+{% block content %}
+
+
💱 Kantor – przelicz walutę
+
+ {% if error %}
+
{{ error }}
+ {% endif %}
+
+
+
+ {% if result %}
+
+ Wynik: {{ amount }} {{ from_currency }} = {{ result|floatformat:2 }} {{ to_currency }}
+
+ {% endif %}
+
+
+ ← Powrót do menu
+
+
+{% endblock %}
\ No newline at end of file
diff --git a/Budget_Project/Budget_Application/templates/core/menu.html b/Budget_Project/Budget_Application/templates/core/menu.html
new file mode 100644
index 0000000..fff659e
--- /dev/null
+++ b/Budget_Project/Budget_Application/templates/core/menu.html
@@ -0,0 +1,23 @@
+
+
+{% extends 'core/base.html' %}
+{% load static %}
+
+{% block content %}
+
+{% endblock %}
\ No newline at end of file
diff --git a/Budget_Project/Budget_Application/urls.py b/Budget_Project/Budget_Application/urls.py
index c6a95f6..7c95c01 100644
--- a/Budget_Project/Budget_Application/urls.py
+++ b/Budget_Project/Budget_Application/urls.py
@@ -61,4 +61,9 @@
path('reset/done/',
auth_views.PasswordResetCompleteView.as_view(template_name='users_test/password_reset_complete.html'),
name='password_reset_complete'),
+ #-----------MENU_APLIKACJI----------->
+ path('menu/', views.main_menu, name='main_menu'),
+ path('income/', views.add_income, name='add_income'),
+ path('expense/', views.add_expense, name='add_expense'),
+ path('currency/', views.currency_converter, name='currency_converter'),
]
diff --git a/Budget_Project/Budget_Application/views.py b/Budget_Project/Budget_Application/views.py
index 410a873..37efd16 100644
--- a/Budget_Project/Budget_Application/views.py
+++ b/Budget_Project/Budget_Application/views.py
@@ -29,6 +29,7 @@
)
from .services import UserService
+import requests
class AllUserTransactionsView(View):
@@ -749,3 +750,110 @@ class MyPasswordResetView(PasswordResetView):
def form_valid(self, form):
response = super().form_valid(form)
return response
+
+
+def main_menu(request):
+ return render(request, 'core/menu.html')
+
+
+def add_income(request):
+ if request.method == 'POST':
+ amount = request.POST.get('amount')
+ category = request.POST.get('cartegory')
+ print(f'Przychód: {amount} ({category})')
+ return render(request, 'core/thanks.html')
+ return render(request, 'core/add_income.html')
+
+def add_expense(request):
+ if request.method == 'POST':
+ amount = request.POST.get('amount')
+ category = request.POST.get('category')
+ print(f'Wydatek: {amount} ({category})')
+ return render(request, 'core/thanks.html')
+ return render(request, 'core/add_expense.html')
+
+
+def get_supported_currencies():
+ url = "https://api.frankfurter.app/currencies"
+ response = requests.get(url)
+ if response.status_code != 200:
+ raise Exception("Błąd pobierania walut.")
+ return response.json()
+
+
+def convert_currency(amount, from_currency, to_currency):
+ if from_currency == to_currency:
+ return amount
+
+ url = "https://api.frankfurter.app/latest"
+ params = {
+ "amount": amount,
+ "from": from_currency,
+ "to": to_currency
+ }
+ response = requests.get(url, params=params)
+ if response.status_code != 200:
+ raise Exception("Błąd przeliczania waluty.")
+
+ data = response.json()
+ return data["rates"][to_currency]
+
+
+def currency_converter(request):
+ result = None
+ error = None
+ currencies = {}
+ from_currency = 'PLN' # domyślna wartość
+ to_currency = ''
+ amount = ''
+
+ try:
+ currencies = get_supported_currencies()
+ except Exception as e:
+ error = str(e)
+
+ if request.method == 'POST':
+ try:
+ amount = request.POST.get('amount')
+ from_currency = request.POST.get('from_currency') or 'PLN'
+ to_currency = request.POST.get('to_currency')
+
+ result = convert_currency(float(amount), from_currency, to_currency)
+ except Exception as e:
+ error = str(e)
+
+ return render(request, 'core/currency_converter.html', {
+ 'currencies': currencies,
+ 'result': result,
+ 'error': error,
+ 'amount': amount,
+ 'from_currency': from_currency,
+ 'to_currency': to_currency,
+ })
+
+
+# def currency_converter(request):
+# result = None
+# error = None
+# currencies = {}
+#
+# try:
+# currencies = get_supported_currencies()
+# except Exception as e:
+# error = str(e)
+#
+# if request.method == 'POST':
+# try:
+# amount = float(request.POST.get('amount'))
+# from_currency = request.POST.get('from_currency') or 'PLN'
+# to_currency = request.POST.get('to_currency')
+#
+# result = convert_currency(amount, from_currency, to_currency)
+# except Exception as e:
+# error = str(e)
+#
+# return render(request, 'core/currency_converter.html', {
+# 'currencies': currencies,
+# 'result': result,
+# 'error': error
+# })
diff --git a/Budget_Project/Budget_Project/settings.py b/Budget_Project/Budget_Project/settings.py
index 76e7cc3..1a2f977 100644
--- a/Budget_Project/Budget_Project/settings.py
+++ b/Budget_Project/Budget_Project/settings.py
@@ -76,7 +76,7 @@
'ENGINE': 'django.db.backends.mysql',
'NAME': 'budget_application_database',
'USER': 'root',
- 'PASSWORD': 'Soniapies_13',
+ 'PASSWORD': 'root',
'HOST': 'localhost',
'PORT': '3306',
}
diff --git a/app_zarz_bud_MENU.py b/app_zarz_bud_MENU.py
index 611982a..740df3c 100644
--- a/app_zarz_bud_MENU.py
+++ b/app_zarz_bud_MENU.py
@@ -42,7 +42,7 @@ def menu():
elif choice == "7":
users.menu_users()
elif choice == "0":
- "***Do ZoBaCzEnIA***"
+ "***Do ZoBaCzEnIA***"
break
else:
print("BŁĄD.... Spróbuj ponownie....")