...
 
Commits (3)
......@@ -51,7 +51,20 @@ class Home extends Component {
return (
<main style={mainStyle} className={this.props.layoutCentered ? 'landingpage-centered-ctr' : ''}>
<div className={`landingpage ${this.props.layoutCentered ? 'landingpage-centered' : ''}`}>
<div className="landingpage-html-content" dangerouslySetInnerHTML={{ __html: instance.htmlContent }} />
<article>
<section className={instance.questionnaires && instance.questionnaires.length > 0 ? 'col-1' : ''}>
<div className="landingpage-html-content" dangerouslySetInnerHTML={{ __html: instance.htmlContent }} />
</section>
{instance.questionnaires && instance.questionnaires.length > 0 && (
<section className="col-2">
{instance.questionnaires.map(quest => (
<div className="btn-ctr" key={quest.id}>
<a href={`/a/${quest.slug}`}>{quest.short_name || quest.name}</a>
</div>
))}
</section>
)}
</article>
<footer>
<div className="logo-recoded">
<a className="logo" href={SETTINGS.COMPANY_URL} rel="noopener noreferrer" target="_blank">
......
# Generated by Django 2.2.7 on 2020-06-25 06:09
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('base_page', '0023_instanceimage_instancelogo'),
]
operations = [
migrations.AddField(
model_name='instancesettings',
name='display_questionnaire_list',
field=models.BooleanField(default=True),
),
]
......@@ -174,10 +174,9 @@ class OrganizationSetting(BackgroundMixin):
@property
def questionnaires(self):
from geoforms.models import Questionnaire
return Questionnaire.objects.filter(Q(organization=self.organization)
& ~Q(deleted=True) & ~Q(name__iexact='')
& (Q(start_date__lte=now().date()))
& (Q(end_date__gte=now().date()) | Q(end_date__isnull=True)))\
return Questionnaire.objects\
.active()\
.filter(organization=self.organization)\
.order_by('name')
@property
......@@ -248,6 +247,7 @@ class InstanceSettings(SingletonModelMixin, BackgroundMixin):
validators=[FileExtensionValidator(settings.IMAGE_EXTENSIONS)])
title = models.CharField(max_length=50, default=_('test page'))
blurb = models.CharField(max_length=120, default=_('Help us improve our City'))
display_questionnaire_list = models.BooleanField(default=True)
class Meta:
verbose_name_plural = _('Instance settings')
......
......@@ -115,6 +115,12 @@ class InstanceSettingsSerializer(serializers.Serializer):
background = BackgroundSerializer(source='*', read_only=True)
title = serializers.CharField(read_only=True)
blurb = serializers.CharField(read_only=True)
questionnaires = serializers.SerializerMethodField()
def get_questionnaires(self, obj):
if not obj.display_questionnaire_list:
return []
return QuestionnaireLandingPageSerializer(Questionnaire.objects.active(), many=True).data
class StaticPageSerializerMixin(serializers.ModelSerializer):
......
from django.db import models
from django.db.models import Q
from django.utils.timezone import now
class QuestionnaireQuerySet(models.QuerySet):
def active(self):
return self.filter(~Q(deleted=True) & ~Q(name__iexact='')
& (Q(start_date__lte=now().date()))
& (Q(end_date__gte=now().date()) | Q(end_date__isnull=True)))
class QuestionnaireManager(models.Manager):
def get_queryset(self):
# Important!
return QuestionnaireQuerySet(self.model, using=self._db).order_by('id')
def active(self):
return self.get_queryset().active()
......@@ -21,6 +21,7 @@ from base_page.helpers import uuslug
from base_page.models import StaticPageMixin
from maps.models import Map
from .helpers import unique_filename
from .managers import QuestionnaireManager
@python_2_unicode_compatible
......@@ -309,6 +310,8 @@ class Questionnaire(models.Model):
is_frozen = models.BooleanField(default=False, verbose_name=_('Questionnaire frozen'))
default_lang = models.CharField(max_length=2, default='pl')
objects = QuestionnaireManager()
class Meta:
verbose_name = _('questionnaire')
verbose_name_plural = _('questionnaires')
......@@ -336,7 +339,6 @@ class Questionnaire(models.Model):
return responses['response_count']
def get_export_header(self):
inputs = {}
header = {_("Session"): 0,
......@@ -521,7 +523,8 @@ class QuestionnairePage(models.Model):
questionnaire = models.ForeignKey(Questionnaire, verbose_name=_('questionnaire'), on_delete=models.CASCADE)
form = models.ForeignKey(Form, verbose_name=_('page'), related_name='order_provider', on_delete=models.CASCADE)
order = models.IntegerField(default=10, verbose_name=_('order'))
next_page = models.ForeignKey(Page, null=True, blank=True, default=None, related_name='prv_page_link', on_delete=models.CASCADE)
next_page = models.ForeignKey(Page, null=True, blank=True, default=None,
related_name='prv_page_link', on_delete=models.CASCADE)
class Meta:
verbose_name = _('questionnaire page')
......@@ -724,7 +727,8 @@ class InputOption(models.Model):
element = models.ForeignKey(Input, related_name='options', on_delete=models.CASCADE)
value = models.CharField(max_length=200, verbose_name=_('option'))
# target? do wywalenia, przy skokach uzywane
target = models.ForeignKey(Form, related_name='targets', null=True, blank=True, default=None, on_delete=models.CASCADE)
target = models.ForeignKey(Form, related_name='targets', null=True,
blank=True, default=None, on_delete=models.CASCADE)
order = models.IntegerField(null=True, blank=True)
class Meta:
......