Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Under improvement -Event page #236

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/events/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class EventAdmin(admin.ModelAdmin):
list_display = ('title', 'schedule', 'venue')
search_fields = ('title', 'venue')
ordering = ('-schedule',)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert back all the changes in this file. Remove this tab and an extra line inserted at the end of this file.


@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
Expand Down Expand Up @@ -70,3 +70,4 @@ def get_event_title(self, obj):
return obj.event.title
get_event_title.short_description = 'Event Title'
get_event_title.admin_order_field = 'event__title'

8 changes: 7 additions & 1 deletion apps/events/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Event(models.Model):
schedule = models.DateTimeField()
venue = models.CharField(max_length=50)
thumbnail = models.ImageField(
upload_to=event_thumbmail_path, null=True, blank=True)
upload_to='events/images', null=True, blank=True)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already fetching the path where the thumbnail needs to be saved from the event_thumbnail_path function. You should revert back this change.

If you want to get the URL of the thumbnail, you can simply use <event>.get_thumbnail_url.


def __str__(self):
return self.title
Expand All @@ -27,6 +27,12 @@ def get_thumbnail_url(self):
else:
return settings.STATIC_URL + 'home/images/02.jpg'

class Gallery(models.Model):
post = models.CharField(max_length=200)
images = models.ImageField(upload_to = 'gallery/image',null=True ,blank=True)

def __str__(self):
return self.post
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a new Gallery model?? Gallery model is already present in the file (last model). Also, what do you mean by the post field here?


class Team(models.Model):
team_id = models.CharField(max_length=50, unique=True)
Expand Down
3 changes: 3 additions & 0 deletions apps/events/static/events/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.container{
background-color: aqua;
}
Binary file added apps/events/templates/events/img/02.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added apps/events/templates/events/img/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions apps/events/templates/events/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{% extends 'layout.html' %}

{% block title %} Jagrati | Events {% endblock %}

{% block style %}

.col-md-3
{
display: inline-block;
margin-top:-10px;
margin-left:-4px;
}
.carousel-indicators .active {
background-color: blue;
}
.col-md-3 img{
margin:3rem 3rem;
width: 170px;
height: 200px;
}

body .carousel-indicator li active{
background-color: blue;
margin-top:10px;
}
body .carousel-indicator li unable{
background-color: grey;
margin-top:10px;
}
body .carousel-indicators{
bottom: 2rem;
}
body .carousel-control-prev-icon,
body .carousel-control-next-icon{
background-color: blue;
}
<!--slider buttons-->
.carousel-control-prev,
.carousel-control-next{
top: auto;
bottom: auto;
padding-top: 222px;
}
body .no-padding{
padding-left: 0,
padding-right: 0;
}
{% endblock %}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent the CSS above properly, it is not readable. You may use Alt + Shift + F in VSCode to auto-indent everything.


{% block content %}
{% load static %}
<div class="container">
<h1>Events list</h1>
<div id="demo" class="carousel slide my-3" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo" data-slide-to="0" class="active"></li>

{% for i in range %}
<li data-target="#demo" data-slide-to="{{i}}" class="unable"></li>
{% endfor %}
</ul>

<!--Slideshow starts here -->
<div class="container carousel-inner no-padding">

<div class="carousel-item active">
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src='/media/{{event.0.thumbnail}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{event.0.venue}}</h5>
<p class="card-text">{{event.0.description}}</p>
<a href="/events/show_event/{{event.0.id}}"><button id="qv{{event.0.id}}" class="btn btn-primary">QuickView</button></a>
</div>
</div>
</div>


{% for i in event|slice:"1:" %}
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card" style="width: 18rem;">
<img src='/media/{{i.thumbnail}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">{{i.venue}}</h5>
<p class="card-text">{{i.description}}</p>
<a href="/events/show_event/{{i.id}}"><button id="qv{{i.id}}" class="btn btn-primary cart">QuickView</button></a>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:3 and forloop.counter > 0 and not forloop.last %}
</div><div class="carousel-item">
{% endif %}

{% endfor %}
</div>



</div>
</div>
<!-- left and right controls for the slide -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>



</div>


{% endblock %}
137 changes: 137 additions & 0 deletions apps/events/templates/events/show_event.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{% extends 'layout.html' %}

{% block title %} Jagrati | {{my_event.title}} {% endblock %}

{% block style %}

.upper{
width: 100%;
height:90%;
border-radius:3%;
box-shadow: 1.2rem 1.2rem 1.7rem #C0C0C0;
}

.upper img{

border-radius:5%;
box-shadow: .8rem .2rem 1.2rem #C0C0C0;
}

.title {
text-transform:uppercase;
}

.title .text1{
font-family: 'Mulish', sans-serif;
}
.col-md-3
{
display: inline-block;
margin-left:-4px;
}
.carousel-indicators .active {
background-color: blue;
}
.col-md-3 img{
width: 170px;
height: 200px;
}
body .carousel-indicator li{
background-color: blue;
}
body .carousel-indicators{
bottom: 0;
}
body .carousel-control-prev-icon,
body .carousel-control-next-icon{
background-color: blue;
}
.carousel-control-prev,
.carousel-control-next{
top: auto;
bottom: auto;
padding-top: 222px;
}
body .no-padding{
padding-left: 0,
padding-right: 0;
}

{% endblock %}

{% block content %}
{% load static %}
<div class="container">
<h1 class="title">
<center>
<span class="text1"><b>event</b></span><br>
<span class="text2">description</span>
</center>
</h1>
<div class="container my-4">
<div class="upper">
<div class="row">
<div class="col-md-4 my-5">
<center>
<img src="/media/{{my_event.thumbnail}}" width="70%" height="60%"></center>

</div>
<div class="col-md-8 my-4">
<h5>{{my_event.title}}</h5>
<p><b>About event:</b> {{my_event.description}}</p>
<p>{{my_event.venue}}</p>
</div>

</div>
</div>
</div>


<div class="gallery">
<!--Slideshow starts here -->
{% for event, range, nSlides in all_events %}
<h1>Particular {{event.0.event_id}}</h1>
<div class="row">
<div id="demo{{forloop.counter}}" class="col carousel slide my-3" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo{{forloop.counter}}" data-slide-to="0" class="active"></li>
{% for i in range %}
<li data-target="#demo{{forloop.parentloop.counter}}" data-slide-to="{{i}}"></li>
{% endfor %}
</ul>
<div class="container carousel-inner no-padding">
<div class="carousel-item active">
{% for i in event %}

<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card align-items-center" style="width: 18rem;">
<img src='/media/{{i.images}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title" id="namepr{{i.id}}">{{i.event_id}}</h5>
<p>Here we have image collection</p>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:4 and forloop.counter > 0 and not forloop.last %}
</div>
<div class="carousel-item">
{% endif %}

{% endfor %}
</div>

</div>
</div>
<!-- left and right controls for the slide -->
<a class="carousel-control-prev" href="#demo" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>

{% endfor %}
</div>


{% endblock %}
8 changes: 6 additions & 2 deletions apps/events/urls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from django.contrib import admin
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see admin being used anywhere.

from django.urls import path

from django.conf import settings
from django.conf.urls.static import static

from . import views

app_name = 'events'
urlpatterns = [
path('', views.index, name='index'),
path('add/', views.add_event, name='add_event'),
]
path('show_event/<int:myid>',views.show_event,name='show_event'),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use pk instead of myid to represent a primary key input.

]+static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to add this here. It is already added in Jagrati.urls.py.

36 changes: 33 additions & 3 deletions apps/events/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,40 @@
from django.http import HttpResponse
from django.shortcuts import render

from django.shortcuts import render,get_object_or_404
from .models import Event,Gallery
from math import ceil

def index(request):
return HttpResponse('Hello World!')
events = Event.objects.all()
print(events)
n = len(events)
nSlides = n//4 + ceil((n/4)-(n//4))
params = {'no_of_slides':nSlides, 'range': range(1,nSlides),'event': events}

return render(request,'events/index.html',params)


def add_event(request):
return HttpResponse('Add events page..')

def show_event(request,myid):
all_event=[]
event = Event.objects.filter(id=myid)

all_image=Gallery.objects.filter(id=myid)
all_title=Gallery.objects.values('event_id','id')
tit = {item['event_id'] for item in all_title }

for t in tit:
print("T: ",t)
# print("selected id: ",)
event_list = Gallery.objects.filter(event_id=t)
n = len(event_list)
nSlides = n // 4 + ceil((n / 4) - (n // 4))
if t==myid:
all_event.append([event_list, range(1, nSlides), nSlides])
break
print(event_list)
params = {'my_event':event[0],'all_events': all_event}
return render(request, 'events/show_event.html',params)


1 change: 1 addition & 0 deletions home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
path('dashboard/', views.dashboard, name='dashboard'),
path('dashboard/update_cwhw/', views.update_cwhw, name='update_cwhw'),
path('ajax/dashboard/', views.ajax_dashboard, name='ajax_dashboard'),

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this extra line from here.

]
1 change: 1 addition & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,4 @@ def ajax_dashboard(request):
data[sch.section.section_id] = sch.section.name

return JsonResponse(data)

2 changes: 1 addition & 1 deletion static/global/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ html, body {
label {
font-weight:600;
letter-spacing:1.2px;
}
}
1 change: 1 addition & 0 deletions static/home/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -937,3 +937,4 @@ footer{
width: 70%;
}
}

2 changes: 1 addition & 1 deletion templates/home/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ <h1><span onclick="document.querySelector('.navbar a:first-child').click()"
<a class="nav-link" href="#about-us">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Events</a>
<a class="nav-link" href="{% url 'events:index' %}">Events</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Team</a>
Expand Down
Loading