Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/.vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"python.pythonPath": "env\\Scripts\\python.exe"
}
7 changes: 5 additions & 2 deletions src/MODU/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ def get_json_from(json, setting):
# https://docs.djangoproject.com/en/2.1/ref/settings/#std:setting-INSTALLED_APPS
INSTALLED_APPS = [
# Add your apps here to enable them
'search.apps.SearchConfig',
'users.apps.UsersConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
Expand Down Expand Up @@ -162,5 +164,6 @@ def get_json_from(json, setting):

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.1/howto/static-files/
STATIC_URL = 'static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'

#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
33 changes: 14 additions & 19 deletions src/MODU/urls.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
"""
MODU URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/2.1/topics/http/urls/

Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
import assessment.views

# Uncomment next two lines to enable admin:
#from django.contrib import admin
#from django.urls import path
from django.urls import path, include
from users import views as user_views


urlpatterns = [
path('search/', include('search.urls')),
path('signup/',user_views.signup,name="signup"),
# Uncomment the next line to enable the admin:
#path('admin/', admin.site.urls)
path('admin/', admin.site.urls),

#assessment
path('mypage/assessment/', assessment.views.project_list.as_view(), name = 'project_list'),
path('mypage/assessment/<int:p_id>', assessment.views.developer_list.as_view(), name = 'developer_list'),
path('mypage/assessment/<int:p_id>/<int:u_id>', assessment.views.assessment, name = 'assessment')
]
Empty file added src/assessment/__init__.py
Empty file.
12 changes: 12 additions & 0 deletions src/assessment/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from django.contrib import admin
from ..model.models import Project, Developer, Assessment
from .forms import AssessmentForm

admin.site.register(Project)
admin.site.register(Developer)

@admin.register(Assessment)
class AssessmentAdmin(admin.ModelAdmin):
form = AssessmentForm

# Register your models here.
5 changes: 5 additions & 0 deletions src/assessment/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class AssessmentConfig(AppConfig):
name = 'assessment'
23 changes: 23 additions & 0 deletions src/assessment/forms.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from django import forms
from ..model.models import Assessment, Developer
from .widgets import CounterTextInput, starWidget

class AssessmentForm(forms.ModelForm):
class Meta:
model = Assessment
field = [
'score_ideation',
'score_development',
'score_communication',
'score_other',
'opinion'
]
widgets ={
'score_ideation' : starWidget,
'score_development' : starWidget,
'score_communication' : starWidget,
'score_other' : starWidget,
'opinion': CounterTextInput,
}


Empty file.
4 changes: 4 additions & 0 deletions src/assessment/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from django.db import models


# Create your models here.
3 changes: 3 additions & 0 deletions src/assessment/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
42 changes: 42 additions & 0 deletions src/assessment/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from django.shortcuts import render, get_object_or_404, redirect
from django.views.generic import ListView
from ..model.models import Project, Developer, Assessment
from .forms import AssessmentForm

# Create your views here.

#상호평가 버튼 클릭시
def project_list(ListView):

context_object_name = 'project_list'

def get_queryset(self):
queryset = Developer.objects.filter(u_id = self.request.session.get('u_id')).value('member_of')
return queryset

#프로젝트 선택시
def developer_list(request, projectID):

context_object_name = 'developer_list'
project = get_object_or_404(Project, p_id = projectID)

def get_queryset(self):
queryset = Developer.objects.all()
queryset = queryset.filter(member_of = project)
queryset = queryset.exclude(u_id = self.request.session.get('u_id')).valude('name') #developer model에 name 필드 추가?

return queryset



#개발자 선택시
def assessment(request, projectID, developerID):
if request.method =="POST":
form = AssessmentForm(request.POST)
if form.is_valid():
form.save()
return redirect('')

return:
form = AssessmentForm()
return
60 changes: 60 additions & 0 deletions src/assessment/widgets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
from django import forms

class CounterTextInput(forms.TextInput):
template_name = "widgets/counter_text.html"

"""
<!-- templates/widgets/counter_text.html -->

{% include "django/forms/widgets/input.html" %}

<span id="counter_{{widget.attrs.id}}"></span>

<script>
document.querySelector('#{{widget.attrs.id}}').addEventListener("input", function(){
document.querySelector("#counter_{{ widget.attrs.id}}").innerHTML = this.value.length + '글자';
})
</script>

"""
class starWidget(forms.TextInput):
input_type = 'rating'
template_name = "widgets/star_rate.html"

class Media:
css = {
'all':[
'widgets/rateit/rateit.css'
]
}
js = [
"//code.jquery.com/jquery-3.4.1.min.js",
'widgets/rateit/jquery.rateit.min.js'
]

def build_attrs(self, *args, **kwargs):
attrs = super().build_attrs(*args, **kwargs)
attrs.update({
'min': 1,
'max': 5,
'step': 1,
})
return attrs

"""

{% load static %}

{% include "django/forms/widgets/input.html" %}

{{ form.media }}

<div id="star_{{ widget.attrs.id }}" class="rateit" data-rateit-backingfld="#{{ widget.attrs.id }}"></div>

<input type="rating" name="grade" value="4" required="" id="id_grade" min="0" max="5" step="1" style="display: none;">

<div id="star_id_grade" class="rateit rateit-bg" data-rateit-backingfld="#id_grade">
<!-- 생략 -->
</div>

"""
Binary file added src/assessment/widgets/rateit/delete.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading