mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-15 23:40:17 +02:00
Allow preset choices for questions in HR (#836)
This commit is contained in:
parent
2ab45b1019
commit
3361d36bbf
@ -6,9 +6,22 @@ from hrapplications.models import ApplicationQuestion
|
|||||||
from hrapplications.models import ApplicationForm
|
from hrapplications.models import ApplicationForm
|
||||||
from hrapplications.models import ApplicationResponse
|
from hrapplications.models import ApplicationResponse
|
||||||
from hrapplications.models import ApplicationComment
|
from hrapplications.models import ApplicationComment
|
||||||
|
from hrapplications.models import ApplicationChoice
|
||||||
|
|
||||||
|
class ChoiceInline(admin.TabularInline):
|
||||||
|
model = ApplicationChoice
|
||||||
|
extra = 0
|
||||||
|
verbose_name_plural = 'Choices (optional)'
|
||||||
|
verbose_name= 'Choice'
|
||||||
|
|
||||||
|
class QuestionAdmin(admin.ModelAdmin):
|
||||||
|
fieldsets = [
|
||||||
|
(None, {'fields': ['title', 'help_text']}),
|
||||||
|
]
|
||||||
|
inlines = [ChoiceInline]
|
||||||
|
|
||||||
admin.site.register(Application)
|
admin.site.register(Application)
|
||||||
admin.site.register(ApplicationComment)
|
admin.site.register(ApplicationComment)
|
||||||
admin.site.register(ApplicationQuestion)
|
admin.site.register(ApplicationQuestion, QuestionAdmin)
|
||||||
admin.site.register(ApplicationForm)
|
admin.site.register(ApplicationForm)
|
||||||
admin.site.register(ApplicationResponse)
|
admin.site.register(ApplicationResponse)
|
||||||
|
33
hrapplications/migrations/0002_choices_for_questions.py
Normal file
33
hrapplications/migrations/0002_choices_for_questions.py
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# Generated by Django 1.11.4 on 2017-08-23 19:46
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
import django.db.models.deletion
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('hrapplications', '0001_initial'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.CreateModel(
|
||||||
|
name='ApplicationChoice',
|
||||||
|
fields=[
|
||||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||||
|
('choice_text', models.CharField(max_length=200, verbose_name='Choice')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name='applicationquestion',
|
||||||
|
name='title',
|
||||||
|
field=models.CharField(max_length=254, verbose_name='Question'),
|
||||||
|
),
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='applicationchoice',
|
||||||
|
name='question',
|
||||||
|
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='choices', to='hrapplications.ApplicationQuestion'),
|
||||||
|
),
|
||||||
|
]
|
@ -11,13 +11,21 @@ from authentication.models import AuthServicesInfo
|
|||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class ApplicationQuestion(models.Model):
|
class ApplicationQuestion(models.Model):
|
||||||
title = models.CharField(max_length=254)
|
title = models.CharField(max_length=254, verbose_name='Question')
|
||||||
help_text = models.CharField(max_length=254, blank=True, null=True)
|
help_text = models.CharField(max_length=254, blank=True, null=True)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "Question: " + self.title
|
return "Question: " + self.title
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
|
class ApplicationChoice(models.Model):
|
||||||
|
question = models.ForeignKey(ApplicationQuestion,on_delete=models.CASCADE,related_name="choices")
|
||||||
|
choice_text = models.CharField(max_length=200, verbose_name='Choice')
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.choice_text
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
class ApplicationForm(models.Model):
|
class ApplicationForm(models.Model):
|
||||||
questions = models.ManyToManyField(ApplicationQuestion)
|
questions = models.ManyToManyField(ApplicationQuestion)
|
||||||
|
@ -5,29 +5,33 @@
|
|||||||
{% block title %}Apply To {{ corp.corporation_name }}{% endblock title %}
|
{% block title %}Apply To {{ corp.corporation_name }}{% endblock title %}
|
||||||
{% block page_title %}{% trans "Apply To" %} {{ corp.corporation_name }}{% endblock page_title %}
|
{% block page_title %}{% trans "Apply To" %} {{ corp.corporation_name }}{% endblock page_title %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<h1 class="page-header text-center">{% trans "Apply To" %} {{ corp.corporation_name }}</h1>
|
<h1 class="page-header text-center">{% trans "Apply To" %} {{ corp.corporation_name }}</h1>
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<div class="col-md-4 col-md-offset-4">
|
<div class="col-md-4 col-md-offset-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<form class="form-signin">
|
<form class="form-signin">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
{% for question in questions %}
|
{% for question in questions %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="control-label" for="id_{{ question.pk }}">{{ question.title }}</label>
|
<label class="control-label" for="id_{{ question.pk }}">{{ question.title }}</label>
|
||||||
<div class=" ">
|
<div class=" ">
|
||||||
{% if question.help_text %}
|
{% if question.help_text %}
|
||||||
<div cass="text-center">{{ question.help_text }}</div>
|
<div cass="text-center">{{ question.help_text }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<textarea class="form-control" cols="40" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="10"></textarea>
|
{% for choice in question.choices.all %}
|
||||||
</div>
|
<input type="radio" name="{{ question.pk }}" id="id_{{ question.pk }}" value="{{ choice.choice_text }}" />
|
||||||
</div>
|
<label for="choice{{ forloop.counter }}">{{ choice.choice_text }}</label><br />
|
||||||
{% endfor %}
|
{% empty %}
|
||||||
<button class="btn btn-lg btn-primary btn-block" type="submit" formmethod="post">{% trans "Submit" %}</button>
|
<textarea class="form-control" cols="30" id="id_{{ question.pk }}" name="{{ question.pk }}" rows="4"></textarea>
|
||||||
</form>
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
<button class="btn btn-lg btn-primary btn-block" type="submit" formmethod="post">{% trans "Submit" %}</button>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user