Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,4 @@ config.json
.idea/
.DS_Store

uploads
20 changes: 20 additions & 0 deletions mooc/migrations/0003_topic_video.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.3 on 2017-08-06 18:09
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('mooc', '0002_topic_title'),
]

operations = [
migrations.AddField(
model_name='topic',
name='video',
field=models.FileField(default='video', upload_to='videos/'),
),
]
6 changes: 4 additions & 2 deletions mooc/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from django.db import models

# Create your models here.


class Topic(models.Model):
content = models.CharField(max_length=10000)
title = models.CharField(max_length=40, default='Title')

title = models.CharField(max_length=40, default='Title')
video = models.FileField(upload_to='videos/', default="video")
7 changes: 7 additions & 0 deletions mooc/templates/mooc/topic.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{% extends 'mooc/_base.html' %}
{% block styles %}
{% load staticfiles %}

<style type="text/css">
#chatbox {
width: 380px;
Expand Down Expand Up @@ -29,6 +31,11 @@ <h2>{{topic.title}}</h2>
<div id="chatbox">
{% include 'bot/chatbox.html' %}
</div>

<video width="320" height="240" controls autoplay>
<source src="{% static video %}" type="video/mp4">
</video>

{% endblock content %}
{% block script %}
{% include 'bot/scripts.html' %}
Expand Down
3 changes: 2 additions & 1 deletion mooc/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from django.conf.urls import url
from mooc.views import *

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

urlpatterns = [
url(r'^$', home, name='home'),
Expand Down
21 changes: 14 additions & 7 deletions mooc/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
from django.shortcuts import render
from mooc.models import Topic

# Create your views here.


def home(request):
print('home')
return render(request, 'mooc/home.html')


def search(request):
print('search')
if request.GET and request.GET.get('query'):
search_results = Topic.objects.filter(title__icontains=request.GET.get('query'))
search_results = Topic.objects.filter(
title__icontains=request.GET.get('query'))
return render(request, 'mooc/search_results.html', context={'results': search_results})


def topic(request):
topic_id=request.GET.get('id')
topic_id = request.GET.get('id')
topic = Topic.objects.filter(id=topic_id).first()
# if topic:
# topic_content = topic.content
# else:
# topic_content =None
return render(request, 'mooc/topic.html',context={'topic_id':topic_id, 'topic': topic})
if topic:
topic_content = topic.content
else:
topic_content =None
video_d = str(topic.video)
return render(request, 'mooc/topic.html', context={'topic_id': topic_id, 'topic': topic, 'content': topic_content, 'video': video_d})
Binary file modified mooc_chatbot/__pycache__/settings.cpython-35.pyc
Binary file not shown.
Binary file modified mooc_chatbot/__pycache__/urls.cpython-35.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion mooc_chatbot/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

STATICFILES_DIRS = (os.path.join(BASE_DIR, "uploads/"), )

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.11/howto/deployment/checklist/
Expand Down