Skip to content

Commit

Permalink
Implement events page
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-kalra committed Apr 29, 2018
1 parent f172642 commit da12274
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 10 deletions.
1 change: 1 addition & 0 deletions home/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
from .models import *

admin.site.register(Resource)
admin.site.register(Events)
11 changes: 10 additions & 1 deletion home/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,13 @@ class Resource(models.Model):
url = models.URLField(max_length=128, db_index=True, blank=False, null=True)

def __str__(self):
return self.title
return self.title

class Events(models.Model):
title = models.CharField(max_length=128, blank=False, null=True)
image=models.FileField(upload_to='events_images/')
brief = models.CharField(max_length=500, blank=False, null=True)
url = models.URLField(max_length=128, db_index=True, blank=False, null=True)

def __str__(self):
return self.title
4 changes: 2 additions & 2 deletions home/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
app_name='home'
urlpatterns = [
url(r'^$', views.Home.as_view(), name = 'home'),
url(r'^resources/', views.Resources.as_view(), name = 'resources')
url(r'^resources/', views.Resources.as_view(), name = 'resources'),
url(r'^events/', views.events.as_view(), name='events'),
]

handler404 = 'Template404.as_view()'

4 changes: 4 additions & 0 deletions home/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,7 @@ class Home(TemplateView):
class Resources(views.View):
def get(self, request, *args, **kwargs):
return render(request, "home/resources/resources.html", {'resources': Resource.objects.all()})

class events(views.View):
def get(self, request, *args, **kwargs):
return render(request, 'home/events/events.html', {'events': Events.objects.all()})
Binary file added media/events_images/cropped-fossasia.png
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 media/events_images/index.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pclubWebsite/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
SECRET_KEY = '$4p#tsin((&rnm!%696^2xutz_-n5k)o&mnwg3z*^f7&--99h&'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
DEBUG = True

ALLOWED_HOSTS = ['*']

Expand Down
4 changes: 3 additions & 1 deletion pclubWebsite/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from django.contrib.auth import views as auth_views
from django.views.generic import TemplateView
from django.views.generic.base import RedirectView
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
url(r'^sw.js', (TemplateView.as_view(template_name="sw.js", content_type='application/javascript', )), name='sw.js'),
Expand All @@ -27,4 +29,4 @@
url(r'^logout/$', auth_views.logout, name='logout'),
url(r'^oauth/', include('social_django.urls', namespace='social')),
url(r'^$', RedirectView.as_view(url='/home/')),
]
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ gunicorn==19.7.1
psycopg2==2.7.3.1
pytz==2017.2
whitenoise==3.3.1
social-auth-app-django==2.1.0
social-auth-app-django==2.1.0
Pillow==5.1.0
7 changes: 3 additions & 4 deletions templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
<!-- Bootstrap -->
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel = 'stylesheet' href="{% static 'home/base.css' %}">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet"/>
Expand Down Expand Up @@ -57,6 +54,7 @@
{% endif %}
<li {% if request.resolver_match.url_name == "home" %}class="active"{% endif %}><a href="{% url 'home:home' %}">Home</a></li>
<li {% if request.resolver_match.url_name == "resources" %}class="active"{% endif %}><a href="{% url 'home:resources' %}">Resources</a></li>
<li {% if request.resolver_match.url_name == "events" %}class="active"{% endif %}><a href="{% url 'home:events' %}">Events</a></li>
{% if user.username %}
<li><a href="{% url 'logout' %}">Logout</a></li>
{% else %}
Expand All @@ -71,6 +69,7 @@
{% endif %}
<li {% if request.resolver_match.url_name == "home" %}class="active"{% endif %}><a href="{% url 'home:home' %}">Home</a></li>
<li {% if request.resolver_match.url_name == "resources" %}class="active"{% endif %}><a href="{% url 'home:resources' %}">Resources</a></li>
<li {% if request.resolver_match.url_name == "events" %}class="active"{% endif %}><a href="{% url 'home:events' %}">Events</a></li>
{% if user.username %}
<li><a href="{% url 'logout' %}">Logout</a></li>
{% else %}
Expand Down
65 changes: 65 additions & 0 deletions templates/home/events/events.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{% extends 'base.html' %}
{% block styles %}
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Bitter|Josefin+Slab">
{%endblock%}
{% block content %}
<div class="container-fluid">

</div>
<ul id = "myTab" class = "nav nav-tabs">
<li class = "active">
<a href = "#upcoming-events" data-toggle = "tab">
Upcoming Events
</a>
</li>

<li><a href = "#past-events" data-toggle = "tab">Past Events</a></li>


</li>

</ul>

<div id = "myTabContent" class = "tab-content">

<div class = "tab-pane fade in active" id = "upcoming-events">
<br>
<div class="card-columns" style="color: black;">
{%if events %}
{% for event in events %}
<div class="card" style="width: 90%; height: 50rem; color: black;">
<img class="card-img-top" height="242" src="{{event.image.url}}" alt="Card image cap">
<div class="card-body">
<br>
<h4 class="card-title" style="font-family: Bitter;">{{event.title}}</h4>
<p class="card-text" style="font-family: Josefin Slab; font-size: 20px;">{{event.brief}}</p>
<a href="{{event.url}}" class="btn btn-primary">Know More</a>
</div>
</div>
{% endfor %}
{% else %}
<h1>No events Yet </h1>
{%endif%}



</div>

</div>

<div class = "tab-pane fade" id = "past-events">


<div class="card-columns" style="color: black;">
<h1>No events yet</h1>
</div>



</div>

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

{% endblock %}

0 comments on commit da12274

Please sign in to comment.