Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
A
ap4-HW-64-issatayev-adlet
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Isataev Adlet
ap4-HW-64-issatayev-adlet
Commits
dfad726e
Commit
dfad726e
authored
Nov 03, 2021
by
Isataev Adlet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Создал полностью CRUD для мероприятий
parent
cbad5e75
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
211 additions
and
6 deletions
+211
-6
requirements.txt
requirements.txt
+1
-0
settings.py
source/speed_dating/settings.py
+4
-1
urls.py
source/speed_dating/urls.py
+7
-0
forms.py
source/webapp/forms.py
+10
-0
models.py
source/webapp/models.py
+1
-1
base.html
source/webapp/templates/base.html
+45
-0
event_create.html
source/webapp/templates/event_create.html
+13
-0
event_delete.html
source/webapp/templates/event_delete.html
+12
-0
event_detail.html
source/webapp/templates/event_detail.html
+13
-0
event_list.html
source/webapp/templates/event_list.html
+12
-0
event_update.html
source/webapp/templates/event_update.html
+13
-0
index.html
source/webapp/templates/index.html
+34
-0
views.py
source/webapp/views.py
+46
-4
No files found.
requirements.txt
View file @
dfad726e
...
@@ -3,3 +3,4 @@ Django==3.2.9
...
@@ -3,3 +3,4 @@ Django==3.2.9
pytz
==2021.3
pytz
==2021.3
sqlparse
==0.4.2
sqlparse
==0.4.2
Pillow
==8.4.0
Pillow
==8.4.0
django-crispy-forms
==1.13.0
source/speed_dating/settings.py
View file @
dfad726e
...
@@ -37,7 +37,8 @@ INSTALLED_APPS = [
...
@@ -37,7 +37,8 @@ INSTALLED_APPS = [
'django.contrib.sessions'
,
'django.contrib.sessions'
,
'django.contrib.messages'
,
'django.contrib.messages'
,
'django.contrib.staticfiles'
,
'django.contrib.staticfiles'
,
'webapp'
'webapp'
,
'crispy_forms'
]
]
MIDDLEWARE
=
[
MIDDLEWARE
=
[
...
@@ -125,5 +126,7 @@ STATIC_URL = '/static/'
...
@@ -125,5 +126,7 @@ STATIC_URL = '/static/'
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
DEFAULT_AUTO_FIELD
=
'django.db.models.BigAutoField'
CRISPY_TEMPLATE_PACK
=
'bootstrap4'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
"uploads"
)
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
"uploads"
)
MEDIA_URL
=
"/uploads/"
MEDIA_URL
=
"/uploads/"
source/speed_dating/urls.py
View file @
dfad726e
...
@@ -17,7 +17,14 @@ from django.conf import settings
...
@@ -17,7 +17,14 @@ from django.conf import settings
from
django.conf.urls.static
import
static
from
django.conf.urls.static
import
static
from
django.contrib
import
admin
from
django.contrib
import
admin
from
django.urls
import
path
from
django.urls
import
path
from
webapp
import
views
as
webapp_views
urlpatterns
=
[
urlpatterns
=
[
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
'admin/'
,
admin
.
site
.
urls
),
path
(
""
,
webapp_views
.
index_view
,
name
=
"index"
),
path
(
"events/"
,
webapp_views
.
EventView
.
as_view
(),
name
=
"list_events"
),
path
(
"events/create/"
,
webapp_views
.
EventCreateView
.
as_view
(),
name
=
"create_events"
),
path
(
"events/<int:pk>/"
,
webapp_views
.
EventDetailView
.
as_view
(),
name
=
"detail_events"
),
path
(
"events/<int:pk>/edit/"
,
webapp_views
.
EventUpdateView
.
as_view
(),
name
=
"update_events"
),
path
(
"events/<int:pk>/delete/"
,
webapp_views
.
EventDeleteView
.
as_view
(),
name
=
"delete_events"
)
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
]
+
static
(
settings
.
MEDIA_URL
,
document_root
=
settings
.
MEDIA_ROOT
)
source/webapp/forms.py
0 → 100644
View file @
dfad726e
from
django
import
forms
from
webapp.models
import
Event
class
EventForm
(
forms
.
ModelForm
):
date
=
forms
.
CharField
(
widget
=
forms
.
TextInput
(
attrs
=
{
'placeholder'
:
'YYYY-MM-DD HH-MM-SS'
}))
class
Meta
:
model
=
Event
fields
=
[
"place"
,
"date"
]
source/webapp/models.py
View file @
dfad726e
...
@@ -21,7 +21,7 @@ class Event(models.Model):
...
@@ -21,7 +21,7 @@ class Event(models.Model):
date
=
models
.
DateTimeField
(
verbose_name
=
"Дата"
)
date
=
models
.
DateTimeField
(
verbose_name
=
"Дата"
)
def
__str__
(
self
):
def
__str__
(
self
):
return
f
'{self.place}'
return
f
'{self.place}
- {self.date}
'
source/webapp/templates/base.html
View file @
dfad726e
<!doctype html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<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/bootstrap@4.6.0/dist/css/bootstrap.min.css"
integrity=
"sha384-B0vP5xmATw1+K9KRQjQERJvTumQW0nPEzvF6L/Z6nronJ3oUOFUFpCjEUQouq2+l"
crossorigin=
"anonymous"
>
<link
rel=
"stylesheet"
href=
"https://cdn.jsdelivr.net/npm/bootstrap-icons@1.5.0/font/bootstrap-icons.css"
>
<title>
{% block title %}{% endblock %}
</title>
</head>
<body>
<nav
class=
"navbar navbar-expand-lg navbar-light bg-light"
>
<a
class=
"navbar-brand"
href=
"{% url 'index' %}"
>
Speed Dating
</a>
<button
class=
"navbar-toggler"
type=
"button"
data-toggle=
"collapse"
data-target=
"#navbarNav"
aria-controls=
"navbarNav"
aria-expanded=
"false"
aria-label=
"Toggle navigation"
>
<span
class=
"navbar-toggler-icon"
></span>
</button>
<div
class=
"collapse navbar-collapse"
id=
"navbarNav"
>
<ul
class=
"navbar-nav"
>
<li
class=
"nav-item active"
>
<a
class=
"nav-link"
href=
"{% url 'list_events' %}"
>
Мероприятия
<span
class=
"sr-only"
>
(current)
</span></a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"{% url 'create_events' %}"
>
Создать мероприятие
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Редактировать профиль
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Войти
</a>
</li>
<li
class=
"nav-item"
>
<a
class=
"nav-link"
href=
"#"
>
Регистрация
</a>
</li>
</ul>
</div>
</nav>
<div
class=
"container"
>
{% block content %}{% endblock %}
</div>
</body>
</html>
\ No newline at end of file
source/webapp/templates/event_create.html
0 → 100644
View file @
dfad726e
{% extends "base.html" %}
{% load crispy_forms_filters %}
{% block title %}Create Event{% endblock %}
{% block content %}
<h1>
Создать Мероприятие
</h1>
<form
action=
"{% url "
create_events
"
%}"
method=
"post"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form|crispy }}
<button>
Создать
</button>
</form>
{% endblock %}
\ No newline at end of file
source/webapp/templates/event_delete.html
0 → 100644
View file @
dfad726e
{% extends "base.html" %}
{% block title %}Delete {{ event.place }}{% endblock %}
{% block content %}
<h2>
Удалить "{{ event.place }}"
</h2>
<a
href=
"{% url "
list_events
"
%}"
>
Cancel
</a>
<form
action=
"{% url "
delete_events
"
event
.
pk
%}"
method=
"post"
>
{% csrf_token %}
<button>
Yes
</button>
</form>
{% endblock %}
\ No newline at end of file
source/webapp/templates/event_detail.html
0 → 100644
View file @
dfad726e
{% extends 'base.html' %}
{% block title %}Events{% endblock %}
{% block content %}
{{ event.place.name }}
<img
src=
"{{ event.place.photo.url }}"
alt=
""
>
{{ event.place.address }}
{{ event.place.description }}
{{ event.date }}
<a
href=
"{% url "
update_events
"
event
.
pk
%}"
>
Редактировать
</a>
<a
href=
"{% url "
delete_events
"
event
.
pk
%}"
>
Удалить
</a>
{% endblock %}
\ No newline at end of file
source/webapp/templates/event_list.html
View file @
dfad726e
{% extends 'base.html' %}
{% block title %}Events{% endblock %}
{% block content %}
{% for event in events %}
<a
href=
"{% url 'detail_events' event.pk %}"
>
{{ event.place }}
</a>
{{ event.date }}
<hr>
{% endfor %}
{% endblock %}
\ No newline at end of file
source/webapp/templates/event_update.html
0 → 100644
View file @
dfad726e
{% extends "base.html" %}
{% load crispy_forms_filters %}
{% block title %}Update Event{% endblock %}
{% block content %}
<h1>
Редактировать Мероприятие
</h1>
<form
action=
"{% url "
update_events
"
event
.
pk
%}"
method=
"post"
enctype=
"multipart/form-data"
>
{% csrf_token %}
{{ form|crispy }}
<button>
Редактировать
</button>
</form>
{% endblock %}
\ No newline at end of file
source/webapp/templates/index.html
0 → 100644
View file @
dfad726e
This diff is collapsed.
Click to expand it.
source/webapp/views.py
View file @
dfad726e
from
django.shortcuts
import
render
from
django.shortcuts
import
render
from
django.views.generic
import
ListView
from
django.urls
import
reverse
,
reverse_lazy
from
django.views
import
View
from
django.views.generic
import
CreateView
,
DetailView
,
UpdateView
,
DeleteView
from
webapp.forms
import
EventForm
from
webapp.models
import
Event
from
webapp.models
import
Event
class
EventView
(
ListView
):
def
index_view
(
request
):
return
render
(
request
,
"index.html"
)
class
EventView
(
View
):
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
events
=
Event
.
objects
.
all
()
context
=
{
"events"
:
events
}
return
render
(
request
,
"event_list.html"
,
context
)
class
EventCreateView
(
CreateView
):
model
=
Event
template_name
=
"event_create.html"
form_class
=
EventForm
def
get_success_url
(
self
):
return
reverse
(
"detail_events"
,
kwargs
=
{
"pk"
:
self
.
object
.
pk
})
class
EventDetailView
(
DetailView
):
model
=
Event
model
=
Event
template_name
=
"event_list.html"
template_name
=
"event_detail.html"
ordering
=
[
"date"
]
context_object_name
=
"event"
class
EventUpdateView
(
UpdateView
):
model
=
Event
template_name
=
"event_update.html"
form_class
=
EventForm
def
get_success_url
(
self
):
return
reverse
(
"detail_events"
,
kwargs
=
{
"pk"
:
self
.
object
.
pk
})
class
EventDeleteView
(
DeleteView
):
model
=
Event
template_name
=
"event_delete.html"
success_url
=
reverse_lazy
(
"list_events"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment