-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kkkkkkkkatya
committed
May 21, 2024
1 parent
f4eddf0
commit f098c8c
Showing
37 changed files
with
521 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from django.forms import ModelForm | ||
from .models import * | ||
from datetime import date | ||
from django.forms import ModelForm, TextInput, Textarea, Select | ||
|
||
|
||
class CreateFeedback(ModelForm): | ||
class Meta: | ||
model = Feedback | ||
fields = ["feedback"] | ||
widgets = { | ||
'feedback': TextInput(attrs={ | ||
'placeholder': "add your comment", | ||
'class': "form-control" | ||
}), | ||
} | ||
|
||
|
||
class CreateReport(ModelForm): | ||
class Meta: | ||
model = Report | ||
topics_choices = Topic.objects.order_by('-id') | ||
fields = ["report", "topic"] | ||
widgets = { | ||
'report': TextInput(attrs={ | ||
'placeholder': "add your comment", | ||
'class': "form-control" | ||
}), | ||
'topic': Select(choices=topics_choices, attrs={ | ||
'placeholder': "horror", | ||
'class': "form-control" | ||
}), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Generated by Django 5.0.2 on 2024-05-15 09:33 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
initial = True | ||
|
||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Feedback', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('feedback', models.TextField(max_length=1000)), | ||
('date_created', models.DateTimeField(auto_now_add=True, null=True)), | ||
('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
], | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 5.0.2 on 2024-05-19 19:16 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('main', '0001_initial'), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Topic', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('name', models.CharField(max_length=200)), | ||
], | ||
), | ||
migrations.CreateModel( | ||
name='Report', | ||
fields=[ | ||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('report', models.TextField(max_length=1000)), | ||
('date_created', models.DateTimeField(auto_now_add=True, null=True)), | ||
('user_id', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), | ||
('topic', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='main.topic')), | ||
], | ||
), | ||
] |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,30 @@ | ||
from django.db import models | ||
from django.contrib.auth.models import User | ||
|
||
|
||
class Topic(models.Model): | ||
name = models.CharField(max_length=200) | ||
|
||
def __str__(self): | ||
return self.name | ||
|
||
|
||
class Feedback(models.Model): | ||
feedback = models.TextField(max_length=1000, blank=False) | ||
user_id = models.ForeignKey(User, blank=False, on_delete=models.CASCADE) | ||
date_created = models.DateTimeField(auto_now_add=True, null=True) | ||
|
||
def __str__(self): | ||
return str(self.feedback) | ||
|
||
|
||
|
||
class Report(models.Model): | ||
report = models.TextField(max_length=1000, blank=False) | ||
user_id = models.ForeignKey(User, blank=False, on_delete=models.CASCADE) | ||
topic = models.ForeignKey(Topic, blank=False, on_delete=models.CASCADE) | ||
date_created = models.DateTimeField(auto_now_add=True, null=True) | ||
|
||
def __str__(self): | ||
return str(self.report) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{% extends 'main/layout.html' %} | ||
|
||
|
||
{% block content %} | ||
<div class="modal modal-sheet position-static d-block bg-body-secondary p-4 py-md-5" tabindex="-1" role="dialog" id="modalSignin"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content rounded-4 shadow"> | ||
<div class="modal-header p-5 pb-4 border-bottom-0"> | ||
<h1 class="fw-bold mb-0 fs-2">Leave your feedback<3</h1> | ||
<a href="{% url 'main:home' %}" > | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> | ||
|
||
</button> | ||
</a> | ||
</div> | ||
|
||
<div class="modal-body p-5 pt-0"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="form-floating mb-3"> | ||
{{ form.feedback }} | ||
<label for="floatingInput">Feedback </label> | ||
</div> | ||
|
||
<button class="w-100 mb-2 btn btn-lg rounded-3 btn-dark" formaction="feedback" | ||
type="submit">Send</button> | ||
|
||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@docsearch/css@3"> | ||
|
||
|
||
<!-- Our project just needs Font Awesome Free's Solid and Brand files --> | ||
|
||
|
@@ -19,6 +21,11 @@ | |
<link href="{% static 'fontawesomefree/css/solid.css' %}" rel="stylesheet" type="text/css"> | ||
<script src="https://kit.fontawesome.com/0c08b70a26.js" crossorigin="anonymous"></script> | ||
|
||
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"> | ||
|
||
|
||
</head> | ||
<body> | ||
<header data-bs-theme="dark"> | ||
|
@@ -105,7 +112,7 @@ | |
<div class="row mt-5 mb-3"></div> | ||
<main class="container"> | ||
{% block content %}{% endblock %} | ||
</main> | ||
|
||
|
||
{% if messages %} | ||
<ul class="messages"> | ||
|
@@ -116,5 +123,42 @@ | |
</ul> | ||
{% endif %} | ||
|
||
<hr class="featurette-divider mt-4"> | ||
|
||
<!-- /END THE FEATURETTES --> | ||
|
||
|
||
|
||
<footer class="container mt-4 mb-7 text-center" style="padding-bottom: 100px;"> | ||
|
||
|
||
|
||
<div class="row mt-4"> | ||
<div class="col-md-3"> | ||
<h6>Help Us</h6> | ||
<p> <a href="{% url 'main:feedback' %}" class="text-decoration-none text-dark"> Leave feedback</a> </p> | ||
<p> <a href="{% url 'main:report' %}" class="text-decoration-none text-dark">Report a problem</a> </p> | ||
</div> | ||
<div class="col-md-3"> | ||
<h6>Contact</h6> | ||
<p>Email: [email protected]</p> | ||
</div> | ||
<div class="col-md-3"> | ||
<h6>Follow Us</h6> | ||
<a href="#" class="me-2"><i class="fab fa-facebook"></i></a> | ||
<a href="#" class="me-2"><i class="fab fa-twitter"></i></a> | ||
<a href="#" class="me-2"><i class="fab fa-instagram"></i></a> | ||
</div> | ||
<div class="col-md-3"> | ||
<a href="#" class="btn btn-dark ">Back to top</a> | ||
</div> | ||
</div> | ||
<!-- Кінець додаткового контенту --> | ||
|
||
</footer> | ||
</main> | ||
<script src="/docs/5.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script> | ||
|
||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{% extends 'main/layout.html' %} | ||
|
||
|
||
{% block content %} | ||
<div class="modal modal-sheet position-static d-block bg-body-secondary p-4 py-md-5" tabindex="-1" role="dialog" id="modalSignin"> | ||
<div class="modal-dialog" role="document"> | ||
<div class="modal-content rounded-4 shadow"> | ||
<div class="modal-header p-5 pb-4 border-bottom-0"> | ||
<h1 class="fw-bold mb-0 fs-2">Create your report</h1> | ||
<a href="{% url 'main:home' %}" > | ||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"> | ||
|
||
</button> | ||
</a> | ||
</div> | ||
|
||
<div class="modal-body p-5 pt-0"> | ||
<form method="post"> | ||
{% csrf_token %} | ||
<div class="form-floating mb-3"> | ||
{{ form.topic }} | ||
<label for="floatingInput">About </label> | ||
</div> | ||
<div class="form-floating mb-3"> | ||
{{ form.report }} | ||
<label for="floatingInput">Problem </label> | ||
</div> | ||
|
||
<button class="w-100 mb-2 btn btn-lg rounded-3 btn-dark" formaction="report" | ||
type="submit">Send</button> | ||
|
||
</form> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
{% endblock %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,66 @@ | ||
from django.shortcuts import render, redirect | ||
from django.shortcuts import render, redirect, get_object_or_404 | ||
from .models import * | ||
from .forms import * | ||
from main.keeper_service import keeper_service | ||
from django.utils import timezone | ||
|
||
# Create your views here. | ||
|
||
### index site ### | ||
def index(request): | ||
return render(request, 'main/home.html') | ||
form = CreateFeedback() | ||
return render(request, 'main/home.html', {'form':form }) | ||
|
||
|
||
def feedback_create(request): | ||
print("request = ", request.POST) | ||
name = request.user | ||
date_created = timezone.now().date | ||
error = '' | ||
form = CreateFeedback(request.POST) | ||
|
||
if request.method == 'POST': | ||
form = CreateFeedback(request.POST) | ||
if form.is_valid(): | ||
feedback = form.save(commit=False) | ||
feedback.user_id = name | ||
feedback.save() | ||
return redirect('main:home') | ||
else: | ||
error = 'Помилки при заповненні форми' | ||
context = { | ||
'form': form, | ||
'error': error, | ||
'name': name, | ||
'date_created': date_created | ||
} | ||
return render(request, 'main/feedback.html', context) | ||
|
||
def report_create(request): | ||
print("request = ", request.POST) | ||
name = request.user | ||
date_created = timezone.now().date | ||
error = '' | ||
form = CreateReport(request.POST) | ||
|
||
if request.method == 'POST': | ||
form = CreateReport(request.POST) | ||
if form.is_valid(): | ||
report = form.save(commit=False) | ||
report.user_id = name | ||
report.save() | ||
return redirect('main:home') | ||
else: | ||
error = 'Помилки при заповненні форми' | ||
context = { | ||
'form': form, | ||
'error': error, | ||
'name': name, | ||
'date_created': date_created | ||
} | ||
return render(request, 'main/report.html', context) | ||
|
||
|
||
|
||
|
||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.