Commit ecaa62f1 authored by Silje Odland's avatar Silje Odland
Browse files

adds profile page, feed app and feed page

parent 801b781b
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" xmlns:margin-left="http://www.w3.org/1999/xhtml"> <html lang="en" xmlns:margin-left="http://www.w3.org/1999/xhtml">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
...@@ -8,7 +9,8 @@ ...@@ -8,7 +9,8 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head> </head>
<body style="background-color:lightblue;">
<body style="background-color: lightblue ">
{% load static%} {% load static%}
<nav class="navbar fixed-top navbar-expand-md bg-light navbar-light"> <nav class="navbar fixed-top navbar-expand-md bg-light navbar-light">
...@@ -24,16 +26,28 @@ ...@@ -24,16 +26,28 @@
<div class="collapse navbar-collapse" id="collapsibleNavbar"> <div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav mr-auto"> <ul class="navbar-nav mr-auto">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#">Hjem</a> <a class="nav-link" href="/startpage", style="font-weight: bold">Rød tråd</a>
<li class="nav-item">
<a class="nav-link" href="#">Utfordringer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Søk</a>
</li>
<!-- Search form -->
<div class="md-form mt-0">
<input class="form-control" type="text" placeholder="Søk etter bruker" aria-label="Search">
</div>
</li> </li>
</ul> </ul>
<ul class="navbar-nav"> <ul class="navbar-nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#">Registrer</a> <a class="nav-link" href="#">Nytt innlegg</a>
</li> </li>
</ul>
<ul class="navbar-nav">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="#">Logg inn</a> <a class="nav-link" href="/myprofile">Min profil</a>
</li> </li>
</ul> </ul>
</div> </div>
...@@ -45,4 +59,3 @@ ...@@ -45,4 +59,3 @@
</div> </div>
</body> </body>
</html> </html>
{% extends 'base.html' %} {% extends 'startbase.html' %}
{% load static %} {% load static %}
{% block body %} {% block body %}
<div style="padding-top: 150px"> <div style="padding-top: 150px">
......
{% extends 'base.html' %}
{% load static %}
{% block body %}
<div style="padding-top: 150px">
<p style="font-size:150%; position: absolute; margin-left:40%; margin-top:-1%">
Navn
</p>
<img src="{% static 'img/profilepic.png' %}" style="width: 10%; margin-left: 25%; margin-top: -5%">
<form>
<div class="form-group" style="margin-left:25%; margin-top:3%">
<p>Litt om meg:</p>
<textarea id="aboutme" rows="3" cols="80" ></textarea>
</div>
</form>
</div>
{% endblock %}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" xmlns:margin-left="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8">
<title>Rød tråd</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script>
</head>
<body style="background-color:lightblue;">
{% load static%}
<nav class="navbar fixed-top navbar-expand-md bg-light navbar-light">
<!-- Brand -->
<a class="" href=" "><img src="{% static 'img/knitting.png' %}" width="40" height="40"></a>
<!-- Toggler/collapsibe Button -->
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar links -->
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="#">Hjem</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Registrer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Logg inn</a>
</li>
</ul>
</div>
</nav>
{% block body %}
{% endblock body %}
</div>
</body>
</html>
{% extends 'base.html' %}
{% load static %}
{% block body %}
{% for post in posts %}
<div style="border-radius: 20px ;margin-top: 100px;width: 60%; margin-left: 20%; background-color: white; height: 420px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<div style="display: block; margin-left: auto; margin-right: auto; padding-top: 50px; width:60%">
<img style="width:100%"; src="{{ post.image.url }}">
</div>
<div style="display: block; margin-left: auto; margin-right: auto; width: 60% ">{{ post.text }}</div>
</div>
{% endfor %}
{% endblock %}
\ No newline at end of file
from django.contrib import admin
from .models import Post
# Register your models here.
admin.site.register(Post)
\ No newline at end of file
from django.apps import AppConfig
class FeedConfig(AppConfig):
name = 'apps.feed'
# Generated by Django 3.0.3 on 2020-02-21 16:32
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Post',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('text', models.TextField(blank=True, max_length=4000, null=True)),
('image', models.ImageField(upload_to='')),
],
),
]
from django.db import models
# Create your models here.
class Post(models.Model):
text = models.TextField(null=True, blank=True,max_length=4000)
image = models.ImageField(null=False)
from django.test import TestCase
# Create your tests here.
from django.shortcuts import render
# Create your views here.
from django.shortcuts import render from django.shortcuts import render
from ..feed.models import Post
# Create your views here. # Create your views here.
def index(request): def index(request):
return render(request, "index.html") return render(request, "index.html")
def startpage(request):
posts = Post.objects.all()
return render(request, "startpage.html", {'posts':posts})
def myprofile(request):
return render(request, "myprofile.html")
\ No newline at end of file
...@@ -37,6 +37,9 @@ INSTALLED_APPS = [ ...@@ -37,6 +37,9 @@ INSTALLED_APPS = [
'django.contrib.sessions', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.messages',
'django.contrib.staticfiles', 'django.contrib.staticfiles',
'apps.users',
'apps.staticpages',
'apps.feed',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
...@@ -123,3 +126,7 @@ STATIC_URL = '/static/' ...@@ -123,3 +126,7 @@ STATIC_URL = '/static/'
STATICFILES_DIRS = [ STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static') os.path.join(BASE_DIR, 'static')
] ]
MEDIA_ROOT = 'uploads/'
MEDIA_URL = '/uploads/'
...@@ -15,12 +15,16 @@ Including another URLconf ...@@ -15,12 +15,16 @@ Including another URLconf
""" """
from django.contrib import admin from django.contrib import admin
from django.urls import path from django.urls import path
from django.conf.urls.static import static
from . import settings
from apps.staticpages.views import index from apps.staticpages.views import index
from apps.staticpages.views import startpage
from apps.staticpages.views import myprofile
urlpatterns = [ urlpatterns = [
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('', index), path('', index),
#path('login/',) path('startpage/', startpage),
] path('myprofile/', myprofile),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
.navbar-nav > li{
padding-left:30px;
padding-right:30px;
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment