comments
This commit is contained in:
parent
885e707ffa
commit
4cfff5de70
Binary file not shown.
BIN
highneed/events/__pycache__/forms.cpython-36.pyc
Normal file
BIN
highneed/events/__pycache__/forms.cpython-36.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,3 +1,4 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import Event
|
||||
# Register your models here.
|
||||
admin.site.register(Event)
|
8
highneed/events/forms.py
Normal file
8
highneed/events/forms.py
Normal file
@ -0,0 +1,8 @@
|
||||
from django import forms
|
||||
|
||||
from .models import Event
|
||||
|
||||
class EventForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = ('title', 'data', 'place')
|
@ -8,7 +8,7 @@ import Login from './Pages/Login';
|
||||
import SearchEvent from './Pages/SearchEvent';
|
||||
import Calendar from './Pages/Calendar';
|
||||
import FBfanpage from './Pages/FBfanpage';
|
||||
|
||||
import views from '../../views.py'
|
||||
|
||||
function App() {
|
||||
return (
|
||||
|
@ -73,7 +73,7 @@ function Home() {
|
||||
</div>
|
||||
|
||||
<div className='article-text'>
|
||||
<h1>Witamy na stronie HighNeed</h1>
|
||||
<h1>Witamy na stronie HighNeed </h1>
|
||||
<p>HighNeed.pl jest portalem do planowania aktywności dla rodzin z dziećmi w Poznaniu.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,10 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Profil</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Hi</h1>
|
||||
</body>
|
||||
</html>
|
23
highneed/events/migrations/0001_initial.py
Normal file
23
highneed/events/migrations/0001_initial.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Generated by Django 3.1.7 on 2021-11-11 16:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Event',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('title', models.CharField(max_length=200)),
|
||||
('data', models.CharField(max_length=11)),
|
||||
('place', models.CharField(max_length=200)),
|
||||
],
|
||||
),
|
||||
]
|
20
highneed/events/migrations/0002_event_pub_date.py
Normal file
20
highneed/events/migrations/0002_event_pub_date.py
Normal file
@ -0,0 +1,20 @@
|
||||
# Generated by Django 3.1.7 on 2021-11-24 22:54
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.utils.timezone
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('events', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='event',
|
||||
name='pub_date',
|
||||
field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date: '),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
Binary file not shown.
Binary file not shown.
@ -1,3 +1,12 @@
|
||||
from django.db import models
|
||||
|
||||
import datetime
|
||||
from django.utils import timezone
|
||||
# Create your models here.
|
||||
class Event(models.Model):
|
||||
pub_date = models.DateTimeField('Date: ')
|
||||
title = models.CharField(max_length=200)
|
||||
data = models.CharField(max_length=11)
|
||||
place = models.CharField(max_length=200)
|
||||
|
||||
def __str__(self):
|
||||
return self.title + ' | ' + self.data + ' | ' + self.place
|
||||
|
29
highneed/events/templates/add_event.html
Normal file
29
highneed/events/templates/add_event.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>AddEvent</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Stwórz wydarzenie</h1>
|
||||
<form method="POST" class="post_form">
|
||||
{% csrf_token %}
|
||||
|
||||
{{ form }}
|
||||
<button type="submit" class="btn btn-success">Save</button>
|
||||
</form>
|
||||
<a href="../">Cancel</a>
|
||||
|
||||
<form action="" method="POST" class="post_form">
|
||||
{% csrf_token %}
|
||||
<label for="event_title">Nazwa: </label>
|
||||
<input id="event_title" type="text" name="event_title" value="{{ current_name }}">
|
||||
<label for="event_date">Data: </label>
|
||||
<input id="event_date" type="text" name="event_date" value="{{ current_name }}">
|
||||
<label for="event_place">Miejsce: </label>
|
||||
<input id="event_place" type="text" name="event_place" value="{{ current_name }}">
|
||||
<button type="submit" class="btn btn-success">Save</button>
|
||||
</form>
|
||||
<a href="../">Cancel</a>
|
||||
</body>
|
||||
</html>
|
@ -3,6 +3,10 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Profil</title>
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">
|
||||
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@ -19,5 +23,68 @@
|
||||
<a href="{% url 'account_login' %}">Log In</a>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
<p><a href="add_event/">Stwórz Wydarzenie</a></p>
|
||||
<br>
|
||||
<p>All {{ numofnews }} news</p>
|
||||
<br>
|
||||
<nav>
|
||||
<h1 class="cat">Events:</h1>
|
||||
{% for i in latest_news_list %}
|
||||
<p>Nazwa: {{ i.title }}</p><b></b>
|
||||
<p>Data: {{ i.data }}</p><b></b>
|
||||
<p>Miasto: {{ i.place }}</p><b></b>
|
||||
<p>Opublikowane: {{ i.pub_date }}</p><br>
|
||||
{% endfor %}
|
||||
</nav>
|
||||
<br>
|
||||
<br>
|
||||
<nav aria-label="Page navigation">
|
||||
{% if users.has_other_pages %}
|
||||
<ul class="pagination">
|
||||
{% if users.has_previous %}
|
||||
<li><a href="?page={{ users.previous_page_number }}">«</a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span>«</span></li>
|
||||
{% endif %}
|
||||
{% for i in users.paginator.page_range %}
|
||||
{% if users.number == i %}
|
||||
<li class="active"><span>{{ i }} <span class="sr-only">(current)</span></span></li>
|
||||
{% else %}
|
||||
<li><a href="?page={{ i }}">{{ i }}</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if users.has_next %}
|
||||
<li><a href="?page={{ users.next_page_number }}">»</a></li>
|
||||
{% else %}
|
||||
<li class="disabled"><span>»</span></li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
</nav>
|
||||
<br>
|
||||
|
||||
<div id="disqus_thread"></div>
|
||||
<script>
|
||||
/**
|
||||
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
|
||||
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables */
|
||||
|
||||
var disqus_config = function () {
|
||||
this.page.url = "https://localhost:8000/profil/"; // Replace PAGE_URL with your page's canonical URL variable
|
||||
this.page.identifier = "comment"; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
|
||||
};
|
||||
|
||||
(function() { // DON'T EDIT BELOW THIS LINE
|
||||
var d = document, s = d.createElement('script');
|
||||
s.src = 'https://highneed.disqus.com/embed.js';
|
||||
s.setAttribute('data-timestamp', +new Date());
|
||||
(d.head || d.body).appendChild(s);
|
||||
})();
|
||||
</script>
|
||||
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
|
||||
<script id="dsq-count-scr" src="//highneed.disqus.com/count.js" async></script>
|
||||
</body>
|
||||
</html>
|
@ -6,5 +6,6 @@ from . import views
|
||||
app_name = 'events'
|
||||
urlpatterns = [
|
||||
path('', views.index, name='events'),
|
||||
path('add_event/', views.create),
|
||||
#path('events/', TemplateView.as_view(template_name='events/index.html'), name='events'),
|
||||
]
|
@ -2,7 +2,57 @@ from django.shortcuts import render
|
||||
|
||||
# Create your views here.
|
||||
from django.http import HttpResponse, HttpResponseRedirect
|
||||
|
||||
|
||||
from django.utils import timezone
|
||||
from .models import Event
|
||||
from .forms import EventForm
|
||||
from django.db.models import Q
|
||||
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
|
||||
def index(request):
|
||||
return HttpResponseRedirect("index.html")
|
||||
latest_news_list = Event.objects.order_by('-pub_date')
|
||||
|
||||
page = request.GET.get('page', 1)
|
||||
paginator = Paginator(latest_news_list, 10)
|
||||
numofnews = len(Event.objects.all())
|
||||
|
||||
try:
|
||||
users = paginator.page(page)
|
||||
except PageNotAnInteger:
|
||||
users = paginator.page(1)
|
||||
except EmptyPage:
|
||||
users = paginator.page(paginator.num_pages)
|
||||
context = {
|
||||
'latest_news_list': latest_news_list,
|
||||
'Title': Event.title,
|
||||
'Data': Event.data,
|
||||
'Place': Event.place,
|
||||
'numofnews': numofnews,
|
||||
}
|
||||
|
||||
return render(request, 'profil.html', context)
|
||||
|
||||
def create(request):
|
||||
|
||||
if request.method == "POST":
|
||||
form = EventForm(request.POST)
|
||||
#adding = Event()
|
||||
|
||||
#adding.title = request.POST.get("Title")
|
||||
#adding.data = request.POST.get("Data")
|
||||
#adding.place = request.POST.get("Place")
|
||||
#adding.country = request.POST.get("Country")
|
||||
#adding.save()
|
||||
|
||||
|
||||
|
||||
if form.is_valid():
|
||||
event = form.save(commit=False)
|
||||
|
||||
event.pub_date = timezone.now()
|
||||
#news.likes = 0
|
||||
event.save()
|
||||
return HttpResponseRedirect("/events/")
|
||||
else:
|
||||
form = EventForm()
|
||||
context = {'form': form}
|
||||
|
||||
return render(request, 'add_event.html', context)
|
Binary file not shown.
Binary file not shown.
@ -141,7 +141,7 @@ if DEBUG:
|
||||
|
||||
ACCOUNT_DEFAULT_HTTP_PROTOCOL = "https"
|
||||
STATIC_URL = '/static/'
|
||||
LOGIN_REDIRECT_URL = '../../events/'
|
||||
LOGIN_REDIRECT_URL = '../../events'
|
||||
LOGOUT_REDIRECT_URL = '../../events/'
|
||||
SESSION_COOKIE_SECURE = False
|
||||
STATICFILES_DIRS = [
|
||||
|
@ -16,6 +16,7 @@ Including another URLconf
|
||||
from django.contrib import admin
|
||||
from django.urls import path, include
|
||||
from django.views.generic import TemplateView
|
||||
from events import views
|
||||
|
||||
urlpatterns = [
|
||||
#path('events/', include('events.urls')),
|
||||
@ -23,5 +24,7 @@ urlpatterns = [
|
||||
path('events/', TemplateView.as_view(template_name='index.html')),
|
||||
path('admin/', admin.site.urls),
|
||||
path('accounts/', include('allauth.urls')),
|
||||
path('profil/', TemplateView.as_view(template_name='profil.html')),
|
||||
path('profil/', views.index, name='profil'),
|
||||
path('profil/add_event/', views.create),
|
||||
#path('profil/add_event/', TemplateView.as_view(template_name='add_event.html')),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user