Skip to content

Commit

Permalink
main
Browse files Browse the repository at this point in the history
  • Loading branch information
ixnur committed Aug 18, 2023
1 parent 4f7be2f commit bc147b9
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 50 deletions.
13 changes: 13 additions & 0 deletions envanter/envanter/authentication.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from django.shortcuts import redirect
from django.urls import reverse

class LoginRequiredMiddleware:
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
if not request.user.is_authenticated and request.path != reverse('login'):
return redirect('login') # Kullanıcı giriş yapmamışsa ve giriş yapma sayfasına yönlendirilir.

response = self.get_response(request)
return response
1 change: 1 addition & 0 deletions envanter/envanter/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'envanter.middlewares.authentication.LoginRequiredMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand Down
65 changes: 16 additions & 49 deletions envanter/envanter/teplates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>envo</title>
<style>
.emptyspace {
margin: 10px;
}


body {
font-family: Arial, sans-serif;
margin: 0;
Expand All @@ -15,14 +20,14 @@
}

header {
background-color: #333;
background-color: #19182c;
padding: 10px 0;
text-align: center;
transition: background-color 0.3s ease;
}

header:hover {
background-color: #555; /* Üzerine gelindiğinde yeni arka plan rengi */
background-color: #3d3863; /* Üzerine gelindiğinde yeni arka plan rengi */
}
nav ul {
padding: 0;
Expand All @@ -41,6 +46,7 @@
color: #fff;
font-weight: bold;
font-size: 16px;
padding-left: auto;
}

.container {
Expand Down Expand Up @@ -129,16 +135,17 @@
<li><a href="/home/nur/Desktop/envanter/envanter/envanter/teplates/index.html">Anasayfa</a></li>
<li><a href="#" id="open-popup">Yeni Parça Ekle</a></li>
<li><a href="/home/nur/Desktop/envanter/envanter/envanter/teplates/profile.html">Profil</a></li>
<div id="stock-table-container">
<form id="search-stock-form" method="GET" action="">
<label for="search-stock">Stok Ara:</label>
<input type="text" id="search-stock" name="search_stock">
<button type="submit">Ara</button>
</form>
</ul>
</nav>
</header>

<div id="stock-table-container">
<form id="search-stock-form" method="GET" action="">
<label for="search-stock">Stok Ara:</label>
<input type="text" id="search-stock" name="search_stock">
<button type="submit">Ara</button>
</form>
<div class="emptyspace">
</div>
<table border="1">
<tr>
<th>Model No</th>
Expand All @@ -161,18 +168,6 @@
</tr>
{% endfor %}
</table>
</div>
<div class="popup2">
<h2>Ürün Detayları</h2>
<p><strong>Model No:</strong> {{ component.model }}</p>
<p><strong>Üretici:</strong> {{ component.manufacturer }}</p>
<p><strong>Kategori:</strong> {{ component.category }}</p>
<p><strong>Paket:</strong> {{ component.package }}</p>
<p><strong>Konum:</strong> {{ component.location }}</p>
<p><strong>Açıklama:</strong> {{ component.technical_specifications }}</p>
<p><strong>Stok Adedi:</strong> {{ component.stock }}</p>
<!-- Diğer detayları burada görüntüleyebilirsiniz -->
<button onclick="closePopup2()">Kapat</button>
</div>
<div id="add-component-popup" class="popup">
<h2>Yeni Komponent Ekle</h2>
Expand Down Expand Up @@ -213,35 +208,8 @@ <h2>Yeni Komponent Ekle</h2>
</form>
<button id="close-popup">Kapat</button>
</div>





<footer>&copy; @mekatronik.org © 2023 Parça Envanteri Uygulaması.</footer>

<script>

window.open(event.target.href, 'Ürün Detayları', 'width=400,height=400,resizable=yes');

</script>
<script>
// Popup açma işlemi
document.addEventListener('click', function(event) {
if (event.target.classList.contains('popup2-link')) {
var componentId = event.target.getAttribute('href').split('/').pop();
var popup = document.getElementById('popup2-' + componentId);
popup.style.display = 'block';
}
});

// Popup kapatma işlemi
document.addEventListener('click', function(event) {
if (event.target.classList.contains('popup2-close')) {
var popup = event.target.closest('.popup2-content');
popup.style.display = 'none';
}
});
// JavaScript kodları burada yer alacak
const openPopupBtn = document.getElementById('open-popup');
const addComponentPopup = document.getElementById('add-component-popup');
Expand All @@ -256,5 +224,4 @@ <h2>Yeni Komponent Ekle</h2>
});
</script>
</body>

</html>
1 change: 0 additions & 1 deletion envanter/envanter/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@
path('parca_ekle', views.parca_ekle, name='parca_ekle'), # URL'yi doğru şekilde belirtin
path('register/', auth_views.RegisterView.as_view(), name='register'),
path('login/', auth_views.LoginView.as_view(), name='login'),
path('component/<int:component_id>/', views.component_detail, name='component_detail'),
]
5 changes: 5 additions & 0 deletions envanter/envanter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
from django.contrib.auth.views import LoginView
from django.shortcuts import render, get_object_or_404
from .models import Component
from django.contrib.auth.decorators import login_required

@login_required
def profile(request):
return render(request, 'index.html')

def component_detail(request, component_id):
component = get_object_or_404(Component, pk=component_id)
Expand Down

0 comments on commit bc147b9

Please sign in to comment.