Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurii Purdenko committed Feb 6, 2024
1 parent 0efe36f commit bd565f0
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 17 deletions.
20 changes: 15 additions & 5 deletions bhtom2/bhtom_observatory/rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,31 @@ def update(self, instance, validated_data):

class DataProductSerializer(serializers.ModelSerializer):
observatory = serializers.SerializerMethodField()
user = serializers.SerializerMethodField()
user_name = serializers.SerializerMethodField()
target_name = serializers.SerializerMethodField()

target = serializers.SerializerMethodField()
user = serializers.SerializerMethodField()

class Meta:
model = DataProduct
fields = '__all__'

def get_user(self, obj):
def get_user_name(self, obj):
user_name = obj.observatory.user.username
return user_name


def get_user(self, obj):
user = obj.observatory.user.id
return user

def get_observatory(self, obj):
observatory_name = obj.observatory.observatory.name
return observatory_name

def get_target_name(self, obj):
target_name = obj.target.name if obj.target else None
return target_name
return target_name

def get_target(self, obj):
target = obj.target.id if obj.target else None
return target
28 changes: 19 additions & 9 deletions bhtom2/external_service/data_source_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class DataSource(Enum):
GAIA_ALERTS = auto()
CPCS = auto()
ASASSN = auto()
OGLE_EWS= auto()
OGLE_EWS = auto()
ZTF = auto()
ATLAS = auto()
AAVSO = auto()
Expand All @@ -23,12 +23,15 @@ class DataSource(Enum):
DECAPS = auto()
GAIA_DR3 = auto()
GAIA_DR2 = auto()
KMT_NET= auto()
KMT_NET = auto()
LOFAR = auto()
twomass = auto()
PTF = auto()


PRETTY_SURVEY_NAME: Dict[DataSource, str] = {
DataSource.GAIA_ALERTS: "Gaia Alerts",
# "GAIA": "Gaia",
# "GAIA": "Gaia",
DataSource.ZTF: "ZTF",
DataSource.CPCS: "CPCS",
DataSource.AAVSO: "AAVSO",
Expand All @@ -46,16 +49,19 @@ class DataSource(Enum):
DataSource.FIRST: "FIRST",
DataSource.PS1: "PS1",
DataSource.DECAPS: "DECAPS",
DataSource.OGLE_EWS:"OGLE-EWS",
DataSource.ATLAS:"ATLAS",
DataSource.KMT_NET:"KMT-NET"
DataSource.OGLE_EWS: "OGLE-EWS",
DataSource.ATLAS: "ATLAS",
DataSource.KMT_NET: "KMT-NET",
DataSource.LOFAR: "LOFAR2m",
DataSource.twomass: "2MASS",
DataSource.PTF: "PTF"
}


def get_pretty_survey_name(source_name: DataSource) -> str:
return PRETTY_SURVEY_NAME.get(source_name, str(source_name))



TARGET_NAME_KEYS: Dict[DataSource, str] = {
DataSource.GAIA_ALERTS: "Gaia Alerts name",
DataSource.ZTF: "ZTF name",
Expand All @@ -76,11 +82,15 @@ def get_pretty_survey_name(source_name: DataSource) -> str:
DataSource.FIRST: "FIRST name",
DataSource.PS1: "PS1 name",
DataSource.DECAPS: "DECAPS name",
DataSource.ATLAS:"ATLAS url",
DataSource.KMT_NET:"KMT name"
DataSource.ATLAS: "ATLAS url",
DataSource.KMT_NET: "KMT name",
DataSource.LOFAR: "LOFAR2m name",
DataSource.twomass: "2MASS name",
DataSource.PTF: "PTF"
}



FILTERS: Dict[DataSource, List[str]] = {
DataSource.GAIA_ALERTS: ["G"],
DataSource.ZTF: ["g", "i", "r"],
Expand Down
4 changes: 2 additions & 2 deletions bhtom2/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from dotenv import dotenv_values

from bhtom2.external_service.data_source_information import DataSource, TARGET_NAME_KEYS
from bhtom2.external_service.data_source_information import DataSource, TARGET_NAME_KEYS, get_pretty_survey_name

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)

Expand Down Expand Up @@ -402,7 +402,7 @@


def generate_name_tuple(data_source: DataSource) -> tuple:
return data_source.name, f'{data_source.name} name'
return data_source.name, f'{get_pretty_survey_name(data_source)} name'


SOURCE_CHOICES = [generate_name_tuple(ds) for ds in DataSource]
Expand Down
2 changes: 1 addition & 1 deletion bhtom2/templates/bhtom_targets/partials/target_table.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<table class="table table-hover sortable">
<thead>
<tr>
<th><label><input type="checkbox" id="selectPage" onClick="select_page(this, {{ target_count }})" /></label>
<th><label><input type="checkbox" id="selectPage" onClick="select_page(this, {{ object_list|length }})" /></label>
</th>
<th>Names</th>
<th>RA</th>
Expand Down

0 comments on commit bd565f0

Please sign in to comment.