diff --git a/highneed/events/__pycache__/admin.cpython-36.pyc b/highneed/events/__pycache__/admin.cpython-36.pyc index 6b106a1..99bfd37 100644 Binary files a/highneed/events/__pycache__/admin.cpython-36.pyc and b/highneed/events/__pycache__/admin.cpython-36.pyc differ diff --git a/highneed/events/__pycache__/forms.cpython-36.pyc b/highneed/events/__pycache__/forms.cpython-36.pyc new file mode 100644 index 0000000..9d27aae Binary files /dev/null and b/highneed/events/__pycache__/forms.cpython-36.pyc differ diff --git a/highneed/events/__pycache__/models.cpython-36.pyc b/highneed/events/__pycache__/models.cpython-36.pyc index 99e7182..e0b8fbe 100644 Binary files a/highneed/events/__pycache__/models.cpython-36.pyc and b/highneed/events/__pycache__/models.cpython-36.pyc differ diff --git a/highneed/events/__pycache__/views.cpython-36.pyc b/highneed/events/__pycache__/views.cpython-36.pyc index cf45080..43fd113 100644 Binary files a/highneed/events/__pycache__/views.cpython-36.pyc and b/highneed/events/__pycache__/views.cpython-36.pyc differ diff --git a/highneed/events/admin.py b/highneed/events/admin.py index 8c38f3f..ba76366 100644 --- a/highneed/events/admin.py +++ b/highneed/events/admin.py @@ -1,3 +1,4 @@ from django.contrib import admin - +from .models import Event # Register your models here. +admin.site.register(Event) \ No newline at end of file diff --git a/highneed/events/forms.py b/highneed/events/forms.py new file mode 100644 index 0000000..edeebfd --- /dev/null +++ b/highneed/events/forms.py @@ -0,0 +1,8 @@ +from django import forms + +from .models import Event + +class EventForm(forms.ModelForm): + class Meta: + model = Event + fields = ('title', 'data', 'place') \ No newline at end of file diff --git a/highneed/events/highneed_react/src/App.js b/highneed/events/highneed_react/src/App.js index a726a2e..9f3b875 100644 --- a/highneed/events/highneed_react/src/App.js +++ b/highneed/events/highneed_react/src/App.js @@ -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 ( diff --git a/highneed/events/highneed_react/src/Pages/Home.js b/highneed/events/highneed_react/src/Pages/Home.js index 225f49d..da38748 100644 --- a/highneed/events/highneed_react/src/Pages/Home.js +++ b/highneed/events/highneed_react/src/Pages/Home.js @@ -73,7 +73,7 @@ function Home() {
-

Witamy na stronie HighNeed

+

Witamy na stronie HighNeed

HighNeed.pl jest portalem do planowania aktywności dla rodzin z dziećmi w Poznaniu.

diff --git a/highneed/events/highneed_react/src/components/profil.html b/highneed/events/highneed_react/src/components/profil.html deleted file mode 100644 index 8a85c01..0000000 --- a/highneed/events/highneed_react/src/components/profil.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - - Profil - - -

Hi

- - \ No newline at end of file diff --git a/highneed/events/migrations/0001_initial.py b/highneed/events/migrations/0001_initial.py new file mode 100644 index 0000000..19594c3 --- /dev/null +++ b/highneed/events/migrations/0001_initial.py @@ -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)), + ], + ), + ] diff --git a/highneed/events/migrations/0002_event_pub_date.py b/highneed/events/migrations/0002_event_pub_date.py new file mode 100644 index 0000000..f315694 --- /dev/null +++ b/highneed/events/migrations/0002_event_pub_date.py @@ -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, + ), + ] diff --git a/highneed/events/migrations/__pycache__/0001_initial.cpython-36.pyc b/highneed/events/migrations/__pycache__/0001_initial.cpython-36.pyc new file mode 100644 index 0000000..f18f31f Binary files /dev/null and b/highneed/events/migrations/__pycache__/0001_initial.cpython-36.pyc differ diff --git a/highneed/events/migrations/__pycache__/0002_event_pub_date.cpython-36.pyc b/highneed/events/migrations/__pycache__/0002_event_pub_date.cpython-36.pyc new file mode 100644 index 0000000..09d1009 Binary files /dev/null and b/highneed/events/migrations/__pycache__/0002_event_pub_date.cpython-36.pyc differ diff --git a/highneed/events/models.py b/highneed/events/models.py index 71a8362..bbb6ffc 100644 --- a/highneed/events/models.py +++ b/highneed/events/models.py @@ -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 diff --git a/highneed/events/templates/add_event.html b/highneed/events/templates/add_event.html new file mode 100644 index 0000000..7cb53b8 --- /dev/null +++ b/highneed/events/templates/add_event.html @@ -0,0 +1,29 @@ + + + + + AddEvent + + +

Stwórz wydarzenie

+
+ {% csrf_token %} + + {{ form }} + +
+Cancel + +
+ {% csrf_token %} + + + + + + + +
+Cancel + + \ No newline at end of file diff --git a/highneed/events/templates/profil.html b/highneed/events/templates/profil.html index 10f10eb..c257968 100644 --- a/highneed/events/templates/profil.html +++ b/highneed/events/templates/profil.html @@ -3,6 +3,10 @@ Profil + + + + @@ -19,5 +23,68 @@ Log In {% endif %} {% endblock %} + + + +

Stwórz Wydarzenie

+
+

All {{ numofnews }} news

+
+ +
+
+ +
+ +
+ + + \ No newline at end of file diff --git a/highneed/events/urls.py b/highneed/events/urls.py index fe94837..8a0f2fb 100644 --- a/highneed/events/urls.py +++ b/highneed/events/urls.py @@ -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'), ] \ No newline at end of file diff --git a/highneed/events/views.py b/highneed/events/views.py index 9157884..bc801a8 100644 --- a/highneed/events/views.py +++ b/highneed/events/views.py @@ -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) \ No newline at end of file diff --git a/highneed/highneed/__pycache__/settings.cpython-36.pyc b/highneed/highneed/__pycache__/settings.cpython-36.pyc index 0dd4a97..96c0db4 100644 Binary files a/highneed/highneed/__pycache__/settings.cpython-36.pyc and b/highneed/highneed/__pycache__/settings.cpython-36.pyc differ diff --git a/highneed/highneed/__pycache__/urls.cpython-36.pyc b/highneed/highneed/__pycache__/urls.cpython-36.pyc index 553a47d..76ef887 100644 Binary files a/highneed/highneed/__pycache__/urls.cpython-36.pyc and b/highneed/highneed/__pycache__/urls.cpython-36.pyc differ diff --git a/highneed/highneed/settings.py b/highneed/highneed/settings.py index c1f996b..444df39 100644 --- a/highneed/highneed/settings.py +++ b/highneed/highneed/settings.py @@ -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 = [ diff --git a/highneed/highneed/urls.py b/highneed/highneed/urls.py index b5e9ebc..5ed1f28 100644 --- a/highneed/highneed/urls.py +++ b/highneed/highneed/urls.py @@ -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')), ]