(self, validated_data)
| 337 | return instance |
| 338 | |
| 339 | def create(self, validated_data): |
| 340 | # Pop exp_date — it's written to the default profile after creation |
| 341 | exp_date = validated_data.pop("exp_date", None) |
| 342 | |
| 343 | # Pop cron_expression — it's not a model field |
| 344 | cron_expr = validated_data.pop("cron_expression", "") |
| 345 | |
| 346 | # Handle enable_vod preference and auto_enable_new_groups settings during creation |
| 347 | enable_vod = validated_data.pop("enable_vod", False) |
| 348 | auto_enable_new_groups_live = validated_data.pop("auto_enable_new_groups_live", True) |
| 349 | auto_enable_new_groups_vod = validated_data.pop("auto_enable_new_groups_vod", True) |
| 350 | auto_enable_new_groups_series = validated_data.pop("auto_enable_new_groups_series", True) |
| 351 | |
| 352 | # Parse existing custom_properties or create new |
| 353 | custom_props = validated_data.get("custom_properties") or {} |
| 354 | if not isinstance(custom_props, dict): |
| 355 | custom_props = ensure_custom_properties_dict(custom_props) |
| 356 | |
| 357 | # Set preferences (default to True for auto_enable_new_groups) |
| 358 | custom_props["enable_vod"] = enable_vod |
| 359 | custom_props["auto_enable_new_groups_live"] = auto_enable_new_groups_live |
| 360 | custom_props["auto_enable_new_groups_vod"] = auto_enable_new_groups_vod |
| 361 | custom_props["auto_enable_new_groups_series"] = auto_enable_new_groups_series |
| 362 | validated_data["custom_properties"] = custom_props |
| 363 | |
| 364 | # Build instance manually so we can attach transient attr before save triggers signal |
| 365 | instance = M3UAccount(**validated_data) |
| 366 | instance._cron_expression = cron_expr |
| 367 | instance.save() |
| 368 | |
| 369 | # Write exp_date through to the default profile created by post_save signal |
| 370 | if exp_date is not None: |
| 371 | default_profile = instance.profiles.filter(is_default=True).first() |
| 372 | if default_profile: |
| 373 | default_profile.exp_date = exp_date |
| 374 | default_profile.save() |
| 375 | |
| 376 | return instance |
| 377 | |
| 378 | def get_filters(self, obj): |
| 379 | # Sort over the prefetch cache; .order_by() would fire one SELECT |
no test coverage detected