diff --git a/cfp/decorators.py b/cfp/decorators.py index 40964bc..ffab13f 100644 --- a/cfp/decorators.py +++ b/cfp/decorators.py @@ -11,9 +11,12 @@ from cfp.models import Participant def speaker_required(view_func): def wrapped_view(request, **kwargs): speaker_token = kwargs.pop('speaker_token') - # TODO v3: if no speaker token is provided, we should check for a logged user, and if so, - # we should check if his/her participating at current conference - speaker = get_object_or_404(Participant, site=request.conference.site, token=speaker_token) + if speaker_token: + speaker = get_object_or_404(Participant, site=request.conference.site, token=speaker_token) + elif request.user.is_authenticated(): + speaker = get_object_or_404(Participant, site=request.conference.site, email=request.user.email) + else: + raise PermissionDenied kwargs['speaker'] = speaker return view_func(request, **kwargs) return wraps(view_func)(wrapped_view) diff --git a/cfp/forms.py b/cfp/forms.py index ec862e1..09892a3 100644 --- a/cfp/forms.py +++ b/cfp/forms.py @@ -195,22 +195,12 @@ class TalkActionForm(forms.Form): self.fields['room'].choices = [(None, "---------")] + list(rooms.values_list('slug', 'name')) -class ParticipantForm(OnSiteNamedModelForm): +class NotifyForm(forms.Form): notify = forms.BooleanField(initial=True, required=False, label=_('Notify by mail?')) - def __init__(self, *args, **kwargs): - social = kwargs.pop('social', True) - ask_notify = kwargs.pop('ask_notify', False) - super().__init__(*args, **kwargs) - if not social: - for field in ['twitter', 'linkedin', 'github', 'website', 'facebook', 'mastodon']: - self.fields.pop(field) - if not ask_notify: - self.fields.pop('notify') - class Meta: - model = Participant - fields = ['name', 'email', 'biography', 'twitter', 'linkedin', 'github', 'website', 'facebook', 'mastodon'] +class ParticipantForm(OnSiteNamedModelForm): + SOCIAL_FIELDS = ['twitter', 'linkedin', 'github', 'website', 'facebook', 'mastodon'] def clean_email(self): email = self.cleaned_data['email'] @@ -220,11 +210,6 @@ class ParticipantForm(OnSiteNamedModelForm): return email -class ParticipantStaffForm(ParticipantForm): - class Meta(ParticipantForm.Meta): - fields = ['name', 'vip', 'email', 'phone_number', 'notes'] + ParticipantForm.Meta.fields[3:] - - class ParticipantFilterForm(forms.Form): category = forms.MultipleChoiceField( label=_('Category'), diff --git a/cfp/models.py b/cfp/models.py index f35d182..7eefe79 100644 --- a/cfp/models.py +++ b/cfp/models.py @@ -115,6 +115,10 @@ class Participant(PonyConfModel): objects = ParticipantManager() + + def get_absolute_url(self): + return reverse('participant-details', kwargs=dict(participant_id=self.token)) + def get_secret_url(self, full=False): url = reverse('proposal-dashboard', kwargs={'speaker_token': self.token}) if full: diff --git a/cfp/templates/cfp/proposal_home.html b/cfp/templates/cfp/proposal_home.html index 6622729..88ade6f 100644 --- a/cfp/templates/cfp/proposal_home.html +++ b/cfp/templates/cfp/proposal_home.html @@ -15,11 +15,13 @@