Private
Public Access
1
0

adding survey storage

This commit is contained in:
Sander Roosendaal
2020-01-10 16:09:33 +01:00
parent 1f96ff4fa7
commit 04f0ff5781
10 changed files with 204 additions and 5 deletions

1
.gitignore vendored
View File

@@ -46,6 +46,7 @@ manage.py
# migrations
/rowers/migrations/
/cvkbrno/migrations/
/survey/migrations/
# secrets
config.yaml

View File

@@ -17,7 +17,8 @@ from .models import (
# Register your models here so you can use them in the Admin module
# Rower details directly under the User
# Rower details directly under the User
class RowerInline(admin.StackedInline):
model = Rower
can_delete = False
@@ -73,7 +74,7 @@ class UserAdmin(admin.ModelAdmin):
('Permissions',
{'fields':
('is_active', 'is_staff', 'is_superuser', 'groups', 'user_permissions',)}),)
search_fields = ["username","first_name","last_name","email"]
def rowerplan(self, obj):
@@ -90,7 +91,7 @@ class FavoriteChartAdmin(admin.ModelAdmin):
class C2WorldClassAgePerformanceAdmin(admin.ModelAdmin):
list_display = ('sex','weightcategory','age','distance','power','name','season')
class SiteAnnouncementAdmin(admin.ModelAdmin):
list_display = ('announcement','created','modified','expires','dotweet')
@@ -99,7 +100,7 @@ class TeamAdmin(admin.ModelAdmin):
class TeamInviteAdmin(admin.ModelAdmin):
list_display = ('issuedate','team','user','code')
class TeamRequestAdmin(admin.ModelAdmin):
list_display = ('issuedate','team','user','code')
@@ -136,7 +137,7 @@ class IndoorVirtualRaceResultAdmin(admin.ModelAdmin):
class PaidPlanAdmin(admin.ModelAdmin):
list_display = ('name','shortname','price','paymenttype','paymentprocessor','external_id')
admin.site.unregister(User)
admin.site.register(User,UserAdmin)
admin.site.register(Workout,WorkoutAdmin)

View File

@@ -47,6 +47,7 @@ ALLOWED_HOSTS = CFG['allowed_hosts']
INSTALLED_APPS = [
'rowers',
'survey',
# 'cvkbrno',
'django.contrib.admin',
'django.contrib.auth',

View File

@@ -22,6 +22,7 @@ from django.views.generic import TemplateView
from rowsandall_app.views import rootview, landingview
from django.contrib.auth import views as auth_views
from rowers import views as rowersviews
from survey import views as surveyviews
import django
@@ -65,6 +66,7 @@ urlpatterns += [
{'next_page': '/'},
name='logout',),
re_path(r'^rowers/',include('rowers.urls')),
re_path(r'^survey/',include('survey.urls')),
# re_path(r'^cvkbrno/',include('cvkbrno.urls')),
# re_path(r'^admin/rq/',include('django_rq_dashboard.urls')),
re_path(r'^call\_back',rowersviews.rower_process_callback),

0
survey/__init__.py Normal file
View File

21
survey/admin.py Normal file
View File

@@ -0,0 +1,21 @@
from .models import Response
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
class ResponseInline(admin.StackedInline):
model = Response
fieldsets = (
('User Details',{'fields':('plan','username','email')}),
('Used Features',
{'fields:':
('logging','technical',
'trend','planning','racing','coaching','export','video','interval')}),
('Paid Plan Questions',
{'fields':('capabilities','fallshort','considered','features')})
)
class ResponseAdmin(admin.ModelAdmin):
#inlines = (ResponseInline,)
list_display = ('plan','id','date','capabilities')
admin.site.register(Response,ResponseAdmin)

4
survey/apps.py Normal file
View File

@@ -0,0 +1,4 @@
from django.apps import AppConfig
class SurveyConfig(AppConfig):
name = 'app'

125
survey/models.py Normal file
View File

@@ -0,0 +1,125 @@
from django.contrib.auth.models import User
from django import forms
from django.forms import ModelForm
from django.conf import settings
from django.db import models
from django.utils import timezone
from rowers.database import *
import datetime
def current_day():
return (datetime.datetime.now(tz=timezone.utc)).date()
class Response(models.Model):
planchoices = (
('basic','Free Athlete'),
('freecoach','Free Coach'),
('pro','Pro'),
('plan','Self-Coach'),
('coach','coach'),
)
plan = models.CharField(max_length=150,choices=planchoices,default='basic')
username = models.CharField(max_length=150,unique=True,verbose_name='User Name',blank=True,null=True)
email = models.EmailField(max_length=150,verbose_name='User Email',blank=True,null=True)
date = models.DateField(default=current_day,verbose_name='survey date')
nrworkouts = models.IntegerField(default=0,verbose_name='nr of workouts per week')
nrworkoutsR = models.IntegerField(default=0,verbose_name='nr of workouts per week on Rowsandall')
hearchoices = (
('wordofmouth','Word of mouth'),
('socialmedia','Social Media (Facebook, Twitter)'),
('otherinternet','Other internet'),
('coach','From my Coach/Coachee'),
('other','Other')
)
heard = models.CharField(max_length=150,blank=True,null=True,
default=None,
choices=hearchoices,verbose_name="How did you hear about Rowsandall")
logging = models.BooleanField(default=False,verbose_name='Logging Workouts')
technial = models.BooleanField(default=False,verbose_name='Technical Analysis of workouts')
trend = models.BooleanField(default=False,verbose_name='Trend Analysis of workouts')
planning = models.BooleanField(default=False,verbose_name='Training planning')
racing = models.BooleanField(default=False,verbose_name='Online racing')
coaching = models.BooleanField(default=False,verbose_name='Coaching')
export = models.BooleanField(default=False,verbose_name='Exporting data to other sites')
video = models.BooleanField(default=False,verbose_name='Video Analysis')
interval = models.BooleanField(default=False,verbose_name='Interval editor')
capabilities = models.NullBooleanField(default=None,null=True,blank=True,
verbose_name='Did you get the capabilities and features that you expected out of Rowsandall')
fallshort = models.TextField(max_length=300,blank=True,verbose_name='Where did Rowsandall fall short of your expectations?')
considerchoices = (
('no','No'),
('pro','Yes: Pro'),
('plan','Yes: Self-Coach'),
('coach','Yes: Coach')
)
considered = models.CharField(max_length=150,choices=considerchoices,default=None,null=True,blank=True,
verbose_name='If you are on a Free plan, did you consider one of the paid plans?')
features = models.TextField(max_length=300,blank=True,
verbose_name="What combination of features would entice you to upgrade to a paid plan")
agreechoices = (
('completely_disagree','Completely Disagree'),
('disagree','Disagree'),
('neutral','Neither agree nor disagree'),
('agree','Agree'),
('completely_agree','Completely Agree'),
)
pricing = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="The pricing for plans is clear and understandable"
)
subscription = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="I feel like I get a good value for the price of the subscription"
)
advanced = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="I feel like the advanced features of Rowsandall are easy to use"
)
mobile = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="It is easy to use Rowsandall from a mobile device"
)
developer1 = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="I feel like the developer of Rowsandall is responsive to problems and resolves them quickly"
)
developer2 = models.CharField(
max_length=150,choices=agreechoices,default=None,null=True,blank=True,
verbose_name="I feel like the developer of Rowsandall is responsive to ideas for new features and capabilities"
)
sugchoices = (
('bug','Resolve a bug'),
('newfeature','Add a new feature'),
('improve','Improve the ease of use of the site'),
('easy','Make the site easier to use on mobile devices'),
('other','Other')
)
bug = models.BooleanField(default=False,verbose_name='Resolve a bug')
newfeature = models.BooleanField(default=False,verbose_name='Add a new feature')
improve = models.BooleanField(default=False,verbose_name='Improve the ease of use of the site')
easu = models.BooleanField(default=False,verbose_name='Make the site easier to use on mobile devices')
other = models.BooleanField(default=False,verbose_name='Other')
suggestiontext = models.TextField(
max_length=300,default=None,null=True,blank=True,
verbose_name='My suggestion is (please write a short description of your suggestion)'
)

10
survey/urls.py Normal file
View File

@@ -0,0 +1,10 @@
from django.conf import settings
from django.conf.urls import url, include
from django.urls import path, re_path
import survey.views as views
urlpatterns = [
#re_path(r'^responses/$',views.ResponseList.as_view(),name='responses_view'),
#re_path(r'^response/(?P<pk>\d+)/$',views.ResponseDetail.as_view(),name='response_view')
]

34
survey/views.py Normal file
View File

@@ -0,0 +1,34 @@
from django.shortcuts import render
from django.template.loader import render_to_string
from django.views.generic.edit import UpdateView,DeleteView,CreateView
from django.views.generic import ListView,DetailView
from django.http import (
HttpResponse, HttpResponseRedirect,
JsonResponse,
HttpResponseForbidden, HttpResponseNotAllowed,
HttpResponseNotFound,Http404
)
from django.contrib.auth import authenticate, login, logout
from survey.models import Response
class ResponseList(ListView):
model = Response
template_name = 'response_list.view'
class ResponseCreate(CreateView):
login_required = True
model = Response
template_name = 'response_create.html'
class ResponseUpdate(UpdateView):
login_required = True
model = Response
template_name = 'response_update.html'
class ResponseDetail(DetailView):
login_required = True
model = Response
template_name = 'response.html'