Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ole Gabor Husebø
rodtrad
Commits
da469dd5
Commit
da469dd5
authored
Feb 27, 2020
by
Silje Odland
Browse files
adds user types, posts, login and logout functionality
parent
316ec013
Changes
27
Hide whitespace changes
Inline
Side-by-side
rodTraa/Templates/base.html
View file @
da469dd5
...
...
@@ -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>
...
...
rodTraa/Templates/challenges.html
0 → 100644
View file @
da469dd5
{% 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
rodTraa/Templates/companypost.html
0 → 100644
View file @
da469dd5
{% 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
rodTraa/Templates/editprofile.html
0 → 100644
View file @
da469dd5
{% extends 'startbase.html' %}
{% load static %}
{% load crispy_forms_tags %}
{% block body %}
{% endblock %}
\ No newline at end of file
rodTraa/Templates/login.html
deleted
100644 → 0
View file @
316ec013
<!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
rodTraa/Templates/myprofile.html
View file @
da469dd5
...
...
@@ -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
rodTraa/Templates/postpage.html
View file @
da469dd5
<!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
rodTraa/Templates/register.html
View file @
da469dd5
...
...
@@ -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
M
ed
I D
ag!
</
legend
>
<
header
style=
"font-weight: bold; font-size: 20px; margin-top: 30px; margin-left: 40%
"
>
Bli
m
ed
i d
ag!
</
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>
</form>
</div>
</div>
{% endblock %}
rodTraa/Templates/registration/login.html
0 → 100644
View file @
da469dd5
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 %}
rodTraa/Templates/startbase.html
View file @
da469dd5
...
...
@@ -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>
...
...
rodTraa/apps/feed/admin.py
View file @
da469dd5
from
django.contrib
import
admin
from
.models
import
Post
from
.models
import
Post
,
Challange
# Register your models here.
admin
.
site
.
register
(
Post
)
\ No newline at end of file
admin
.
site
.
register
(
Post
)
admin
.
site
.
register
(
Challange
)
\ No newline at end of file
rodTraa/apps/feed/forms.py
0 → 100644
View file @
da469dd5
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"
)
rodTraa/apps/feed/migrations/0004_post_time.py
0 → 100644
View file @
da469dd5
# 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
)),
),
]
rodTraa/apps/feed/migrations/0005_auto_20200226_2201.py
0 → 100644
View file @
da469dd5
# 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
)),
),
]
rodTraa/apps/feed/migrations/0006_auto_20200226_2201.py
0 → 100644
View file @
da469dd5
# 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
)),
),
]
rodTraa/apps/feed/migrations/0007_auto_20200226_2202.py
0 → 100644
View file @
da469dd5
# 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
),
),
]
rodTraa/apps/feed/migrations/0008_challange.py
0 → 100644
View file @
da469dd5
# 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
)),
],
),
]
rodTraa/apps/feed/migrations/0009_auto_20200227_1420.py
0 → 100644
View file @
da469dd5
# 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
),
),
]
rodTraa/apps/feed/migrations/0010_auto_20200227_1543.py
0 → 100644
View file @
da469dd5
# 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
),
),
]
rodTraa/apps/feed/models.py
View file @
da469dd5
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
)
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment