mirror of
https://github.com/peeringdb/peeringdb.git
synced 2024-05-11 05:55:09 +00:00
website field on carrier optional with org fallback
This commit is contained in:
19
peeringdb_server/migrations/0105_carrier_website_optional.py
Normal file
19
peeringdb_server/migrations/0105_carrier_website_optional.py
Normal file
@@ -0,0 +1,19 @@
|
||||
# Generated by Django 3.2.16 on 2023-01-16 12:41
|
||||
|
||||
from django.db import migrations
|
||||
import django_peeringdb.models.abstract
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('peeringdb_server', '0104_mtu_choices'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='carrier',
|
||||
name='website',
|
||||
field=django_peeringdb.models.abstract.URLField(blank=True, max_length=255, null=True, verbose_name='Website'),
|
||||
),
|
||||
]
|
||||
@@ -1827,8 +1827,6 @@ class CarrierSerializer(ModelSerializer):
|
||||
|
||||
org = serializers.SerializerMethodField()
|
||||
|
||||
website = serializers.URLField()
|
||||
|
||||
def validate_create(self, data):
|
||||
# we don't want users to be able to create carriers if the parent
|
||||
# organization status is pending or deleted
|
||||
@@ -1862,6 +1860,16 @@ class CarrierSerializer(ModelSerializer):
|
||||
return self.sub_serializer(OrganizationSerializer, inst.org)
|
||||
|
||||
|
||||
def to_representation(self, data):
|
||||
|
||||
representation = super().to_representation(data)
|
||||
|
||||
if not representation.get("website"):
|
||||
representation["website"] = self.instance.org.website
|
||||
|
||||
return representation
|
||||
|
||||
|
||||
class InternetExchangeFacilitySerializer(ModelSerializer):
|
||||
"""
|
||||
Serializer for peeringdb_server.models.InternetExchangeFacility
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
<div class="view_field view_sub col-xs-12 col-sm-12 col-md-12">{{ row.label }}</div>
|
||||
{% else %}
|
||||
<!-- row header -->
|
||||
<div class="view_field col-xs-4 col-sm-5 col-md-4{% if row.help_text %} help-text{% endif %}"
|
||||
<div {% if row.edit_label %}data-edit-toggled="view"{% endif %} class="view_field col-xs-4 col-sm-5 col-md-4{% if row.help_text %} help-text{% endif %}"
|
||||
{% if row.help_text %}
|
||||
data-bs-toggle="tooltip"
|
||||
data-placement="top"
|
||||
@@ -134,10 +134,22 @@
|
||||
title="{{ row.help_text }}"
|
||||
{% endif %}>{% if row.notify_incomplete %}<span class="incomplete glyphicon glyphicon-exclamation-sign hidden"></span>{% endif %} {{ row.label }}
|
||||
{% if row.help_text %}<span class="glyphicon glyphicon-question-sign"></span>{% endif %}
|
||||
{% if row.helper_text %}
|
||||
<div data-edit-toggled="edit" style="display:none;" class="help">{{ row.help_text }}</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if row.edit_label %}
|
||||
|
||||
<!-- row header (edit mode), will only be set if `edit_label` is set on the field definition -->
|
||||
|
||||
<div data-edit-toggled="edit" class="view_field col-xs-4 col-sm-5 col-md-4{% if row.help_text or row.edit_help_text %} help-text{% endif %}"
|
||||
{% if row.help_text or row.edit_help_text %}
|
||||
data-bs-toggle="tooltip"
|
||||
data-placement="top"
|
||||
{% if row.notify_incomplete_group %}data-notify-incomplete-group="{{ row.notify_incomplete_group }}"{% endif %}
|
||||
title="{% if row.edit_help_text %}{{ row.edit_help_text }}{% else %}{{ row.help_text }}{% endif %}"
|
||||
{% endif %}>{% if row.notify_incomplete %}<span class="incomplete glyphicon glyphicon-exclamation-sign hidden"></span>{% endif %} {{ row.edit_label }}
|
||||
{% if row.help_text or row.edit_help_text %}<span class="glyphicon glyphicon-question-sign"></span>{% endif %}
|
||||
</div>
|
||||
|
||||
{% endif %}
|
||||
|
||||
<!-- row value -->
|
||||
{% if row.type == "url" %}
|
||||
|
||||
@@ -1854,6 +1854,8 @@ def view_carrier(request, id):
|
||||
"type": "url",
|
||||
"name": "website",
|
||||
"label": _("Company Website"),
|
||||
"edit_label": _("Company Website Override"),
|
||||
"edit_help_text": _("If this field is set, it will be displayed on this record. If not, we will display the website from the organization record this is tied to"),
|
||||
"value": data.get("website", dismiss),
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user