Skip to content

Commit

Permalink
feat(buddy-system): issuer_note
Browse files Browse the repository at this point in the history
  • Loading branch information
thejoeejoee committed Sep 10, 2023
1 parent cf35f0d commit bfef34d
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.2.4 on 2023-09-02 12:04

import django.core.validators
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('accounts', '0016_userprofile_facebook_userprofile_instagram_and_more'),
]

operations = [
migrations.AlterField(
model_name='userprofile',
name='instagram',
field=models.CharField(blank=True, validators=[django.core.validators.RegexValidator('^[\\w\\-_.]+$')], verbose_name='instagram username'),
),
]
12 changes: 6 additions & 6 deletions fiesta/apps/buddy_system/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class NewBuddyRequestForm(BaseModelForm):
class Meta:
model = BuddyRequest
fields = (
"description",
"issuer_note",
"interests",
"responsible_section",
"issuer",
Expand All @@ -42,12 +42,12 @@ class Meta:
"issuer": HiddenInput,
}
labels = {
"description": _("Tell us about yourself"),
"issuer_note": _("Tell us about yourself"),
"interests": _("What are you into?"),
}
help_texts = {
"description": lazy(
lambda: render_to_string("buddy_system/parts/buddy_request_description_help.html"),
"issuer_note": lazy(
lambda: render_to_string("buddy_system/parts/buddy_request_issuer_note_help.html"),
str,
)
}
Expand All @@ -67,15 +67,15 @@ def __init__(self, *args, **kwargs):
if self.instance.state != BuddyRequest.State.CREATED:
self.fields["matched_by"].disabled = True
self.fields["matched_at"].disabled = True
self.fields["description"].disabled = True
self.fields["issuer_note"].disabled = True
self.fields["interests"].disabled = True

class Meta:
model = BuddyRequest
fields = (
"issuer",
"state",
"description",
"issuer_note",
"interests",
"matched_by",
"matched_at",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-02 12:04

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('buddy_system', '0019_alter_buddyrequest_options'),
]

operations = [
migrations.RenameField(
model_name='buddyrequest',
old_name='description',
new_name='issuer_note',
),
]
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ <h2 class="card-title flex flex-row justify-between">
{% endif %}
</div>
</div>
<div class="chat-bubble">{{ br.description }}</div>
<div class="chat-bubble">{{ br.issuer_note }}</div>
</div>
<div class="chat chat-end">
<div class="chat-header">
Expand Down
6 changes: 6 additions & 0 deletions fiesta/apps/fiestarequests/models/configuration.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from django.db import models
from django.utils.translation import gettext_lazy as _

from apps.fiestarequests.matching_policy import MatchingPoliciesRegister
from apps.plugins.models import BasePluginConfiguration
Expand All @@ -23,6 +24,11 @@ class BaseRequestSystemConfiguration(BasePluginConfiguration):
help_text=MatchingPoliciesRegister.DESCRIPTION,
)

enable_note_from_matcher = models.BooleanField(
default=True,
help_text=_("Allows matcher to reply with custom notes to the request issuer"),
)

@property
def matching_policy_instance(self):
# TODO: pass configuration?
Expand Down
16 changes: 12 additions & 4 deletions fiesta/apps/fiestarequests/models/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class State(TextChoices):


def base_request_model_factory(related_base: str):
"""
Creates a base model for requests-like models.
"""

class BaseRequest(LifecycleModelMixin, BaseTimestampedModel):
class Meta(BaseTimestampedModel.Meta):
abstract = True
Expand All @@ -44,8 +48,8 @@ class Meta(BaseTimestampedModel.Meta):

state = models.CharField(
verbose_name=_("state"),
choices=BaseRequestProtocol.State.choices,
default=BaseRequestProtocol.State.CREATED,
choices=State.choices,
default=State.CREATED,
max_length=16,
)
issuer = models.ForeignKey(
Expand Down Expand Up @@ -77,8 +81,12 @@ class Meta(BaseTimestampedModel.Meta):
blank=True,
)

description = models.TextField(
verbose_name=_("description"),
issuer_note = models.TextField(
verbose_name=_("text from issuer"),
)

matcher_note = models.TextField(
verbose_name=_("text from matcher"),
)

@hook(BEFORE_SAVE, when="matched_by", was=None, is_not=None)
Expand Down
18 changes: 18 additions & 0 deletions fiesta/apps/plugins/migrations/0014_alter_plugin_app_label.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.4 on 2023-09-02 12:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('plugins', '0013_alter_plugin_app_label'),
]

operations = [
migrations.AlterField(
model_name='plugin',
name='app_label',
field=models.CharField(choices=[('buddy_system', 'Buddy System'), ('dashboard', 'Dashboard'), ('sections', 'ESN section'), ('esncards', 'ESNcard'), ('pages', 'Pages')], help_text='Defines system application, which specific plugin represents.', max_length=256, verbose_name='app label'),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Generated by Django 4.2.4 on 2023-09-02 12:04

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('sections', '0014_alter_sectionmembership_role'),
]

operations = [
migrations.AlterField(
model_name='sectionsconfiguration',
name='required_gender',
field=models.BooleanField(blank=True, default=None, help_text='Flag if field is needed to fill in user profile: True=field is required, False=field is optional, None=field is not available', null=True, verbose_name='required gender'),
),
migrations.AlterField(
model_name='sectionsconfiguration',
name='required_interests',
field=models.BooleanField(blank=True, default=None, help_text='Flag if field is needed to fill in user profile: True=field is required, False=field is optional, None=field is not available', null=True, verbose_name='required interests'),
),
migrations.AlterField(
model_name='sectionsconfiguration',
name='required_nationality',
field=models.BooleanField(blank=True, default=None, help_text='Flag if field is needed to fill in user profile: True=field is required, False=field is optional, None=field is not available', null=True, verbose_name='required nationality'),
),
migrations.AlterField(
model_name='sectionsconfiguration',
name='required_phone_number',
field=models.BooleanField(blank=True, default=None, help_text='Flag if field is needed to fill in user profile: True=field is required, False=field is optional, None=field is not available', null=True, verbose_name='required phone number'),
),
migrations.AlterField(
model_name='sectionsconfiguration',
name='required_picture',
field=models.BooleanField(blank=True, default=None, help_text='Flag if field is needed to fill in user profile: True=field is required, False=field is optional, None=field is not available', null=True, verbose_name='required profile picture'),
),
]

0 comments on commit bfef34d

Please sign in to comment.