-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from SAZZAD-AMT/ratul
added projects model and views
- Loading branch information
Showing
7 changed files
with
126 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<h1>Logo</h1> | ||
<hr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.