from django import forms
from .models import Incident, Brand

class IncidentForm(forms.ModelForm):
    class Meta:
        model = Incident
        fields = ['brand', 'incident_type', 'source_url', 'content']

    def __init__(self, *args, **kwargs):
        user = kwargs.pop('user', None)
        super(IncidentForm, self).__init__(*args, **kwargs)
        if user:
            self.fields['brand'].queryset = user.brands.all()
