Commit 38314e80 authored by Silje Odland's avatar Silje Odland
Browse files

fixed challange name

parent 79667251
......@@ -55,7 +55,7 @@
<a class="nav-link" href="{% url 'newevent' %}"> Nytt arrangement</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'postpage' %}">Nytt innlegg</a>
<a class="nav-link" href="{% url 'postpage' %}"> Nytt innlegg </a>
</li>
</ul>
......@@ -83,5 +83,6 @@
</div>
<script src="{% static 'js/theme.js' %}"> </script>
</body>
</html>
</html>
\ No newline at end of file
......@@ -5,12 +5,11 @@
<div style="padding-left: 30px; padding-right: 30px">
<div style="border-radius: 20px; margin-top: 90px; min-width: fit-content; max-width: 600px; text-align: center; margin-right: auto; margin-left: auto; 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 style="margin-top: 40px">
<h2> Nytt innlegg </h2>
{% csrf_token %}
<h2> Ny utfording </h2>
<div class="custom-file" style="margin-left: 5%; margin-right: 20%; width: 60%">
<form method="post" enctype="multipart/form-data" action="{% url 'companypost' %}">
{% csrf_token %}
{{ form }}
<button type="submit"> Last opp </button>
</form>
......
......@@ -5,15 +5,24 @@
<div style=" padding-left: 30px; padding-right: 30px;">
<div style="border-radius: 20px; margin-top: 90px; min-width: fit-content; max-width: 600px; text-align: center; margin-right: auto; margin-left: auto; 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)">
<div style="border-radius: 20px; margin-top: 90px; min-width: fit-content; max-width: 600px; text-align: center; margin-right: auto; margin-left: auto; background-color: white; height: fit-content; 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" style="text-align: center; margin-top: 20px ">
{% csrf_token %}
<h2 style="padding-top: 20px"> Nytt innlegg <br></h2>
{% csrf_token %}
{% if privateperson %}
<h2 style="padding-top: 20px"> Nytt innlegg <br></h2>
{% else %}
<h2 style="padding-top: 20px"> Ny utfordring <br></h2>
<label style="text-align: left; margin-top: 20px"> Navnet på utfordringen <br>{{ form.name }} </label><br>
{% endif %}
<label style="margin-top: 20px; text-align: left"> Skriv litt om innlegget her <br>{{ form.text }} </label><br>
<label style="text-align: left"> Last opp et bilde <br> {{ form.image }} </label><br>
<button type="submit" class="btn btn-outline-info" style="margin-top: 30px"> Publiser innlegg </button>
</form>
{% if privateperson %}
<button type="submit" class="btn btn-outline-info" style="margin-top: 30px"> Publiser innlegg </button>
{% else %}
<button type="submit" class="btn btn-outline-info" style="margin-top: 30px"> Publiser utfordring </button>
{% endif %}
</form><br>
</div>
</div>
......
......@@ -13,6 +13,7 @@ class PostForm(forms.ModelForm):
class ChallengeForm(forms.ModelForm):
name = forms.CharField(required=False, widget=forms.Textarea(attrs={'rows': 1, 'cols': 40}))
text = forms.CharField(required=False, widget=forms.Textarea(attrs={'rows': 5, 'cols': 40}))
class Meta:
......
......@@ -15,7 +15,7 @@ class Post(models.Model):
like = models.ManyToManyField(User, blank=True, related_name="like")
class Challange(models.Model):
name = models.TextField(null=True, blank = True, max_length=100)
name = models.TextField(null=True, blank = True, max_length=40)
text = models.TextField(null=True, blank=True, max_length=4000)
image = models.ImageField(null=False)
time = models.DateTimeField(null=True)
......
......@@ -8,7 +8,9 @@ from .models import Post, Event, Challange
# Create your views here.
def postpage(request):
privateperson = False;
if PrivatePerson.objects.filter(user=request.user).first():
privateperson = True;
if request.method == 'POST':
form = PostForm(request.POST, request.FILES)
form.instance.post_owner = request.user
......@@ -19,7 +21,7 @@ def postpage(request):
return redirect('startpage')
else:
form = PostForm()
return render(request, 'postpage.html', {'form': form })
return render(request, 'postpage.html', {'form': form, 'privateperson':privateperson})
else:
if request.method == 'POST':
......@@ -32,9 +34,7 @@ def postpage(request):
return redirect('challenges')
else:
form = ChallengeForm()
return render(request, 'postpage.html', {
'form': form
})
return render(request, 'postpage.html', {'form': form, 'privateperson':privateperson})
def deletePost(request,pk):
post= Post.objects.filter(pk=pk).first()
......
......@@ -28,7 +28,7 @@ def companyprofile(request,pk):
def challenges(request):
challengeposts = Challange.objects.all().order_by('-time')
privateperson = False;
privateperson = False
if PrivatePerson.objects.filter(user=request.user).first():
privateperson = True
return render(request, "challenges.html", {'challengeposts': challengeposts, 'privateperson': privateperson})
......
Markdown is supported
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