Skip to content

Commit

Permalink
Merge branch 'main' into asef
Browse files Browse the repository at this point in the history
  • Loading branch information
asefamer committed Nov 22, 2021
2 parents 460051f + 9ec1cf1 commit bd79c91
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 0 deletions.
46 changes: 46 additions & 0 deletions bdagro/models.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,49 @@
from django.db import models
from django.db.models.deletion import CASCADE
import uuid



class Project(models.Model):

title = models.CharField(max_length=200)
description = models.TextField(null=True, blank=True)

demo_link = models.CharField(max_length=2000, null=True, blank=True)
source_link = models.CharField(max_length=2000, null=True, blank=True)
tags = models.ManyToManyField('Tag', blank=True)
vote_total = models.IntegerField(default=0, null=True, blank=True)
vote_ratio = models.IntegerField(default=0, null=True, blank=True)
created = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)

def __str__(self):
return self.title


class Review(models.Model):
VOTE_TYPE = (
('up', 'Up Vote'),
('down', 'Down Vote'),
)
project = models.ForeignKey(Project, on_delete=models.CASCADE)
body = models.TextField(null=True, blank=True)
value = models.CharField(max_length=200, choices=VOTE_TYPE)
created = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)


def __str__(self):
return self.value


class Tag(models.Model):
name = models.CharField(max_length=200)
created = models.DateTimeField(auto_now_add=True)
id = models.UUIDField(default=uuid.uuid4, unique=True,
primary_key=True, editable=False)

def __str__(self):
return self.name
21 changes: 21 additions & 0 deletions bdagro/templates/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!Doctype html>
<html>
<head>
<head>
<meta charset="UTF-8">
<meta http-equiv='X-UA-Compatible' content ='IE=edge'>
<title> DevSearch</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>

{%include 'navbar.html'%}
{% block content %}

{% endblock content %}

<p>Footer</p>
</body>

</html>

2 changes: 2 additions & 0 deletions bdagro/templates/navbar.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<h1>Logo</h1>
<hr>
27 changes: 27 additions & 0 deletions bdagro/templates/projects/projects.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{% extends 'main.html'%}

{% block content %}

<h1>Projects </h1>
<table>
<tr>
<th>ID</th>
<th>Project</th>
<th>Positive Votes</th>
<th>Votes</th>

</tr>
{% for project in projects %}
<tr>
<td>{{project.id}}</td>
<td>{{project.title}}</td>
<td>{{project.vote_total}}</td>
<td>{{project.vote_ratio}}% </td>
<td>{{project.created}}</td>
<td><a href="{% url 'project' project.id %}">View</a> </td>
</tr>


{% endfor %}
</table>
{% endblock content %}
17 changes: 17 additions & 0 deletions bdagro/templates/projects/single-project.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% extends 'main.html'%}

{% block content %}


<h1> {{project.title}}</h1>
<hr>
{% for tag in project.tags.all %}
<span style="border:1apx solid grey ">{{tag}}</span>
{% endfor %}
<hr>


<br>
<p>{{project.description}}</p>

{% endblock %}
13 changes: 13 additions & 0 deletions bdagro/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
from django.shortcuts import render
from bdagro.models import Project

from user.decorators import unauthenticated_user


@unauthenticated_user
def home(request):
return render(request,"home.html")


def projects(request):
projects=Project.objects.all()
context={'projects': projects }
return render(request, 'projects/projects.html', context)



def project(request,pk):
projectObj=Project.objects.get(id=pk)
return render( request, 'projects/single-project.html',{'project': projectObj})
Binary file modified db.sqlite3
Binary file not shown.

0 comments on commit bd79c91

Please sign in to comment.