Commit a52fb609 authored by Sander Elias Høyland's avatar Sander Elias Høyland
Browse files

Merge branch 'Ole's_Branch' into 'master'

Ole's branch

See merge request tdt4140-2020/58!2
parents f413f873 88028866
......@@ -52,7 +52,15 @@
</ul>
</div>
</nav>
<div class="col-md-8">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{message.tags}}">
{{ message }}
</div>
{% endfor %}
{% endif %}
</div>
{% block body %}
{% endblock body %}
......
......@@ -6,4 +6,4 @@
<p style="font-size:150%; position: absolute; margin-left:10%; margin-top: 5%"><br><br> Registrer ny bruker <br> eller logg inn for å se <br> utfordringer og innhold <br> fra andre brukere </p>
<img src="{% static 'img/profil.png' %}" alt="" style=" width: 38%; margin-left: 45%; margin-top: 12%; transform: translateY(-50%) rotate(-10deg);">
</div>
{% endblock %}
\ No newline at end of file
{% endblock %}
......@@ -11,7 +11,7 @@
<div class="form-group" style="margin-left:10%; margin-top:50px">
<p><i>Litt om meg:</i></p>
<p> {{ knitter.about }} </p>
<p>Her skal info</p>
</div>
</div>
......
{% extends 'startbase.html' %}
{% 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>
{{ form|crispy }}
</fieldset>
<div class="form-group">
<button class="btn btn-outline-info" type="submit">Registrer Deg</button>
</div>
</div>
</form>
</div>
</div>
{% endblock %}
# Generated by Django 3.0.3 on 2020-02-24 19:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('feed', '0002_post_publisher'),
]
operations = [
migrations.RemoveField(
model_name='post',
name='publisher',
),
]
from django.db import models
from ..users.models import Knitter
# Create your models here.
......@@ -8,5 +7,4 @@ from ..users.models import Knitter
class Post(models.Model):
text = models.TextField(null=True, blank=True,max_length=4000)
image = models.ImageField(null=False)
publisher = models.ForeignKey(Knitter, null=True, on_delete=models.CASCADE)
from django.shortcuts import render
from ..feed.models import Post
from ..users.models import Knitter
from django.contrib.auth.models import User
# Create your views here.
def index(request):
......@@ -11,5 +11,5 @@ def startpage(request):
return render(request, "startpage.html", {'posts':posts})
def myprofile(request,pk):
knitter = Knitter.objects.filter(pk=pk).first()
knitter = User.objects.filter(pk=pk).first()
return render(request, "myprofile.html",{'knitter':knitter})
\ No newline at end of file
from django.contrib import admin
from .models import Knitter
# Register your models here.
admin.site.register(Knitter)
\ No newline at end of file
from django import forms
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm
class UserRegisterForm(UserCreationForm):
email = forms.EmailField()
class Meta:
model = User
fields = ['username', 'email', 'password1', 'password2']
\ No newline at end of file
# Generated by Django 3.0.3 on 2020-02-24 19:11
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('users', '0002_knitter_profilepicture'),
]
operations = [
migrations.DeleteModel(
name='Knitter',
),
]
from django.db import models
from django.contrib.auth.models import AbstractUser
# Create your models here.
class Knitter(AbstractUser):
about = models.CharField(max_length=300, null=True, blank=True)
profilepicture = models.ImageField(null= True)
from django.shortcuts import render
from django.shortcuts import render, redirect
from django.contrib import messages
from .forms import UserRegisterForm
# Create your views here.
def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
username = form.cleaned_data.get('username')
messages.success(request, f'Account created for {username}!')
form.save()
return redirect('startpage/')
else:
form = UserRegisterForm()
return render(request, 'register.html', {'form': form})
\ No newline at end of file
......@@ -38,9 +38,11 @@ INSTALLED_APPS = [
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'apps.users',
#'apps.users',
'apps.staticpages',
'apps.feed',
'apps.users.apps.UsersConfig',
'crispy_forms',
]
MIDDLEWARE = [
......@@ -126,11 +128,12 @@ USE_TZ = True
STATIC_URL = '/static/'
CRISPY_TEMPLATE_PACK = 'bootstrap4'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
MEDIA_ROOT = 'uploads/'
MEDIA_URL = '/uploads/'
AUTH_USER_MODEL = 'users.Knitter'
......@@ -19,19 +19,17 @@ from django.urls import path, include
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 startpage
from apps.staticpages.views import myprofile
from apps.users import views as user_views
urlpatterns = [
path('admin/', admin.site.urls),
# Denne linker til startpage/urls.py
]
urlpatterns = [
path('admin/', admin.site.urls),
#path('', index),
#path('myprofile/<int:pk>/', myprofile),
#path('startpage/', include('startpage.urls')),
path('register', user_views.register, name='register'),
path('', index),
path('startpage/', startpage),
path('myprofile/<int:pk>/', myprofile),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
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