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

adds user types, posts, login and logout functionality

parent 316ec013
......@@ -15,7 +15,7 @@
<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>
<a class="" href="{% url 'startpage' %}"><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">
......@@ -26,9 +26,9 @@
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="", style="font-weight: bold">Rød tråd</a>
<a class="nav-link" href="{% url 'startpage' %}", style="font-weight: bold">Rød tråd</a>
<li class="nav-item">
<a class="nav-link" href="#">Utfordringer</a>
<a class="nav-link" href="{% url 'challenges' %}">Utfordringer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Søk</a>
......@@ -42,12 +42,15 @@
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#">Nytt innlegg</a>
<a class="nav-link" href="{% url 'postpage' %}">Nytt innlegg</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="/myprofile">Min profil</a>
<a class="nav-link" href="{% url 'myprofile' user.pk %}">Min profil</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'logout' %}">Logg ut </a>
</li>
</ul>
</div>
......
{% extends 'base.html' %}
{% load static %}
{% block body %}
{% for post in challengeposts %}
<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
{% extends 'base.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
<div style="border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; margin-bottom: 30px; background-color: white; height: 250px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<h2 style="margin-left: 35%; padding-top: 30px">
Nytt innlegg
</h2>
<div class="custom-file" style="margin-left: 5%; margin-right: 20%; margin-top: 10%; width: 60%">
<form method="post" enctype="multipart/form-data" action="{% url 'companypost' %}">
{% csrf_token %}
{{ form }}
<button type="submit"> Last opp </button>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'startbase.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
{% endblock %}
\ No newline at end of file
<!doctype html>
<html>
<head>
<title>Login page</title>
<body>
<h1>Login page of the social media</h1>
</body>
</html>
\ No newline at end of file
......@@ -11,9 +11,17 @@
<div class="form-group" style="margin-left:10%; margin-top:50px">
<p><i>Litt om meg:</i></p>
<p>Her skal info</p>
</div>
</div>
</div>
{% 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
{% extends 'base.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
</body>
</html>
\ No newline at end of file
<div style="border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; margin-bottom: 30px; background-color: white; height: 400px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<form method="post" action="{% url 'postpage' %}" enctype="multipart/form-data">
{% csrf_token %}
{{ form }}
<button type="submit"> Last opp </button>
</form>
</div>
{% endblock %}
\ No newline at end of file
......@@ -2,21 +2,29 @@
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
<div class="content-section">
<div style="border-radius: 20px ;margin-top: 80px;width: 60%; margin-left: 20%; background-color: white; height: 650px; box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);">
<form method="POST" action="{% url 'register' %}">
{% csrf_token %}
<div style="margin-left: 4%; margin-top: 10px; margin-right: 4% " >
<fieldset class = "form-group">
<legend class="border-bottom mb-4">Bli Med I Dag!</legend>
<header style="font-weight: bold; font-size: 20px; margin-top: 30px; margin-left: 40%"> Bli med i dag!</header>
{{ form|crispy }}
</fieldset>
<input type="checkbox" id="company" name="company">
<label for="company" style="margin-bottom: 20px"> Check off if you are a company </label>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Registrer Deg</button>
<button class="btn btn-outline-info" type="submit"> Registrer </button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
from crispy_forms.bootstrap import HorizontalField
{% extends 'startbase.html' %}
{% load static %}
{% block body %}
<div style="border-radius: 20px ;margin-top: 90px;width: 50%; margin-left: 25%; 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);">
<form style="margin-left:30%; padding-top: 30px; margin-right: 30%" method="post">
{% csrf_token %}
<div class="form-group">
<header style="font-weight: bold; font-size: 20px; margin-top: 20px; margin-bottom: 30px; margin-left: 30%"> Logg inn </header>
<label for="username"> Brukernavn </label>
<input type="username" name="username" class="form-control" id="username" aria-describedby="emailHelp" placeholder="Skriv inn brukernavn">
</div>
<div class="form-group">
<label for="exampleInputPassword1"> Passord </label>
<input name="password" type="password" class="form-control" id="exampleInputPassword1" placeholder="Skriv inn passord">
</div>
<button type="submit" class="btn btn-primary" href="/"> Logg inn </button>
</form>
</div>
{% endblock %}
......@@ -13,7 +13,7 @@
<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>
<a class="" href="{% url 'index' %}"><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">
......@@ -24,16 +24,16 @@
<div class="collapse navbar-collapse" id="collapsibleNavbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item">
<a class="nav-link" href="">Hjem</a>
<a class="nav-link" href="{% url 'index' %}">Hjem</a>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="register">Registrer</a>
<a class="nav-link" href="{% url 'register'%}">Registrer</a>
</li>
<li class="nav-item">
<a class="nav-link" href="login">Logg inn</a>
<a class="nav-link" href="{% url 'login' %}">Logg inn</a>
</li>
</ul>
</div>
......
from django.contrib import admin
from .models import Post
from .models import Post, Challange
# Register your models here.
admin.site.register(Post)
admin.site.register(Challange)
\ No newline at end of file
from django import forms
from .models import Post
from .models import Challange
class PostForm(forms.ModelForm):
class Meta:
model = Post
fields = ("text", "image")
exclude = ("time", "post_owner")
class ChallengeForm(forms.ModelForm):
class Meta:
model = Challange
fields = ("text", "image")
exclude = ("time", "post_owner")
# Generated by Django 3.0.3 on 2020-02-26 20:53
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('feed', '0003_remove_post_publisher'),
]
operations = [
migrations.AddField(
model_name='post',
name='time',
field=models.DateTimeField(default=datetime.datetime(2020, 2, 26, 20, 53, 10, 293845, tzinfo=utc)),
),
]
# Generated by Django 3.0.3 on 2020-02-26 21:01
import datetime
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('feed', '0004_post_time'),
]
operations = [
migrations.AddField(
model_name='post',
name='post_owner',
field=models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='post',
name='time',
field=models.DateTimeField(default=datetime.datetime(2020, 2, 26, 21, 1, 28, 659614, tzinfo=utc)),
),
]
# Generated by Django 3.0.3 on 2020-02-26 21:01
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('feed', '0005_auto_20200226_2201'),
]
operations = [
migrations.AlterField(
model_name='post',
name='time',
field=models.DateTimeField(default=datetime.datetime(2020, 2, 26, 21, 1, 38, 103332, tzinfo=utc)),
),
]
# Generated by Django 3.0.3 on 2020-02-26 21:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('feed', '0006_auto_20200226_2201'),
]
operations = [
migrations.AlterField(
model_name='post',
name='time',
field=models.DateTimeField(null=True),
),
]
# Generated by Django 3.0.3 on 2020-02-27 10:46
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('feed', '0007_auto_20200226_2202'),
]
operations = [
migrations.CreateModel(
name='Challange',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('post_owner', models.ForeignKey(null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
],
),
]
# Generated by Django 3.0.3 on 2020-02-27 13:20
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('feed', '0008_challange'),
]
operations = [
migrations.AddField(
model_name='challange',
name='document',
field=models.FileField(null=True, upload_to=''),
),
migrations.AddField(
model_name='challange',
name='uploaded_at',
field=models.DateTimeField(auto_now_add=True, null=True),
),
]
# Generated by Django 3.0.3 on 2020-02-27 14:43
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('feed', '0009_auto_20200227_1420'),
]
operations = [
migrations.RemoveField(
model_name='challange',
name='document',
),
migrations.RemoveField(
model_name='challange',
name='uploaded_at',
),
migrations.AddField(
model_name='challange',
name='image',
field=models.ImageField(default=django.utils.timezone.now, upload_to=''),
preserve_default=False,
),
migrations.AddField(
model_name='challange',
name='text',
field=models.TextField(blank=True, max_length=4000, null=True),
),
migrations.AddField(
model_name='challange',
name='time',
field=models.DateTimeField(null=True),
),
]
from django.db import models
from django.utils import timezone
from django.contrib.auth.models import User
# Create your models here.
......@@ -7,4 +9,11 @@ from django.db import models
class Post(models.Model):
text = models.TextField(null=True, blank=True,max_length=4000)
image = models.ImageField(null=False)
time = models.DateTimeField(null=True)
post_owner = models.ForeignKey(User, on_delete= models.CASCADE, null=True)
class Challange(models.Model):
text = models.TextField(null=True, blank=True, max_length=4000)
image = models.ImageField(null=False)
time = models.DateTimeField(null=True)
post_owner = models.ForeignKey(User, on_delete=models.CASCADE, null=True)
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