Skip to content

Added a journey page #201

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
7 changes: 6 additions & 1 deletion oshc/main/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@

from django.contrib import admin

from main.models import chatSession, Contest
from main.models import chatSession, Contest, Journey


class chatSessionAdmin(admin.ModelAdmin):
list_display = ('title', 'start_date')


class journeyAdmin(admin.ModelAdmin):
list_display = ('title', 'start_date')


class contestAdmin(admin.ModelAdmin):
list_display = ('name', 'link', 'description', 'start_date', 'end_date',
'approved')
Expand All @@ -26,4 +30,5 @@ def approve_contest(self, request, queryset):


admin.site.register(chatSession, chatSessionAdmin)
admin.site.register(Journey, journeyAdmin)
admin.site.register(Contest, contestAdmin)
27 changes: 27 additions & 0 deletions oshc/main/migrations/0002_journey.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.6 on 2017-12-17 21:29
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('main', '0001_initial'),
]

operations = [
migrations.CreateModel(
name='Journey',
fields=[
('id', models.AutoField(auto_created=True,

Choose a reason for hiding this comment

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

trailing whitespace

primary_key=True, serialize=False, verbose_name='ID')),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

('title', models.CharField(help_text='Journey title',

Choose a reason for hiding this comment

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

trailing whitespace

max_length=128)),

Choose a reason for hiding this comment

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

continuation line under-indented for visual indent

('description', models.TextField(help_text='Session details',
max_length=512)),
('start_date', models.DateTimeField()),
],
),
]
9 changes: 9 additions & 0 deletions oshc/main/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,12 @@ class Contest(models.Model):

def __str__(self):
return self.name


class Journey(models.Model):
title = models.CharField(max_length=128, help_text="Journey title")
start_date = models.DateField(null=True)

Copy link
Member

Choose a reason for hiding this comment

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

Can we add a description field too?

Copy link
Member

Choose a reason for hiding this comment

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

We are good w/ these two.

def __str__(self):
return self.title

Choose a reason for hiding this comment

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

blank line at end of file
blank line contains whitespace

69 changes: 69 additions & 0 deletions oshc/main/static/main/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -420,3 +420,72 @@ footer .container {
.subtitle {
margin: 0 !important;
}

/* TIMELINE CHANGES */

body {
background: #d4e5f7;
}

.timeline ul {
background: #d4e5f7;
padding: 50px 0;
}

.timeline ul li {
list-style-type: none;
position: relative;
width: 6px;
margin: 0 auto;
padding-top: 50px;
background: #ffffff;
}

.timeline ul li::after {
content: '';
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
width: 30px;
height: 30px;
border-radius: 50%;
background: inherit;
}

.timeline ul li div {
position: relative;
bottom: 0;
width: 400px;
padding: 15px;
background: #ffffff;
}

.timeline ul li div::before {
content: '';
position: absolute;
bottom: 7px;
width: 0;
height: 0;
border-style: solid;
}

.timeline ul li:nth-child(odd) div {
left: 45px;
}

.timeline ul li:nth-child(odd) div::before {
left: -15px;
border-width: 8px 16px 8px 0;
border-color: transparent #ffffff transparent transparent;
}

.timeline ul li:nth-child(even) div {
left: -439px;
}

.timeline ul li:nth-child(even) div::before {
right: -15px;
border-width: 8px 0 8px 16px;
border-color: transparent transparent transparent #ffffff;
}
3 changes: 2 additions & 1 deletion oshc/main/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
</ul>
</li>
<li><a href="https://github.com/OpenSourceHelpCommunity" target="_blank">Resources</a></li>
<li><a href="{% url 'contests' %}" target="_blank">Contests</a></li>
<li><a href="{% url 'contests' %}" target="_blank">Contests</a></li>
<li><a href="{% url 'journey' %}" target="_blank">Journey</a></li>
Copy link
Member

Choose a reason for hiding this comment

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

I don't think we should put target="_blank" here. The Journey page is part of the OSHC page.

Copy link
Member

@tapaswenipathak tapaswenipathak Dec 24, 2017

Choose a reason for hiding this comment

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

These needs to be removed for quite a few.

<li><a href="mailto:[email protected]" target="_blank">Contact</a></li>
<li><a href="https://opensourcehelp.herokuapp.com/" target="_blank">Join Us!</a></li>
{% if user.is_authenticated %}
Expand Down
22 changes: 22 additions & 0 deletions oshc/main/templates/journey.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% extends 'base.html' %}
{% load static %}
{% block content %}
<section class="timeline">
<body>
<ul>
{% if Journey %}
{% for j in Journey %}
<li>
<div> {{j.start_date}}<br>{{j.title}} </div>
</li>
<!-- more list items here -->
{% endfor %}
{% else %}
<li>
<div> No journey available </div>
</li>
{% endif %}
</ul>
</body>
</section>
{% endblock %}
1 change: 1 addition & 0 deletions oshc/main/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
url(r'^contest_new/', views.contest_new, name="contest_new"),
url(r'^add_contest/', views.add_contest, name="add_contest"),
url(r'^submit_contest/', views.submit_contest, name="submit_contest"),
url(r'^journey/', views.journey, name="journey"),
]
8 changes: 7 additions & 1 deletion oshc/main/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.shortcuts import render
from django.http import HttpResponseRedirect
from main.models import chatSession, Contest
from main.models import chatSession, Contest, Journey
from .forms import ContestForm


Expand Down Expand Up @@ -38,3 +38,9 @@ def add_contest(request):

def submit_contest(request):
return render(request, 'contest_submission.html')


def journey(request):
journey_list = Journey.objects.all()
return render(request, 'journey.html',
context={'Journey': journey_list})
Copy link
Member

@jarifibrahim jarifibrahim Dec 18, 2017

Choose a reason for hiding this comment

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

You might want to sort the journey_list by the start_date before sending it to the HTML page. This ensures that the data we send out of the view is chronologically ordered.
You can use Managers[0] to achieve this or you could do something like Journey.objects.all().filteryBy('start_date')

[0] - https://docs.djangoproject.com/en/2.0/topics/db/managers/

Copy link
Member

Choose a reason for hiding this comment

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

fixed w/ Journey.objects.order_by('start_date').