Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

WIP first draft of add co-speaker feature #925

Open
wants to merge 1 commit into
base: dev/ep2019
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions assopy/models.py
Original file line number Diff line number Diff line change
@@ -145,10 +145,10 @@ def _create_user(
user.assopy_id = assopy_id
user.save()

user_created.send(
sender=user,
profile_complete=(password is not None) or (token is not None),
)
# user_created.send(
# sender=user,
# profile_complete=(password is not None) or (token is not None),
# )

return user

1 change: 1 addition & 0 deletions conference/accounts.py
Original file line number Diff line number Diff line change
@@ -154,6 +154,7 @@ def get_or_create_attendee_profile_for_new_user(user):
attendee.uuid = shortuuid.ShortUUID().random(length=7)
attendee.save()
attendee.setBio('bio')
attendee.save()
return attendee


22 changes: 22 additions & 0 deletions conference/cfp.py
Original file line number Diff line number Diff line change
@@ -27,6 +27,10 @@
)


# TODO: this should have a better location
ADD_CO_SPEAKER = 'add_co_speaker'


@login_required
def submit_proposal_step1_talk_info(request):
"""
@@ -144,10 +148,28 @@ def preview_proposal(request, talk_slug):
talk = get_object_or_404(Talk, slug=talk_slug)
talk_as_dict = dump_relevant_talk_information_to_dict(talk)
conf = Conference.objects.current()

# This might not be best place to do it...
if request.method == 'POST':
if ADD_CO_SPEAKER in request.POST:
speaker, _ = Speaker.objects.get_or_create(user=request.user)
add_speaker_to_talk(speaker, talk)
messages.success(request, "Succesfully added as co-speaker")

print("Nope", request.POST)
return redirect('.')

current_user_is_speaker = (
request.user.id
in talk.speakers.all().values_list('user_id', flat=True)
)

return TemplateResponse(request, "ep19/bs/cfp/preview.html", {
"talk": talk,
"talk_as_dict": talk_as_dict,
"cfp_is_open": conf.cfp(),
"ADD_CO_SPEAKER": ADD_CO_SPEAKER,
"current_user_is_speaker": current_user_is_speaker,
})


Original file line number Diff line number Diff line change
@@ -67,6 +67,10 @@ def handle(self, *args, **options):
active=True,
)

print("setting user_profiles")
for user in alice, bob, cesar:
get_or_create_attendee_profile_for_new_user(user.user)

print("Making some talk proposals")
for user in alice, bob, cesar:
speaker, _ = Speaker.objects.get_or_create(user=user.user)
@@ -75,7 +79,6 @@ def handle(self, *args, **options):
talk.created_by = user.user
talk.save()
add_speaker_to_talk(speaker, talk)
get_or_create_attendee_profile_for_new_user(user.user)

def new_page(rev_id, title, **kwargs):
try:
9 changes: 9 additions & 0 deletions templates/ep19/bs/cfp/preview.html
Original file line number Diff line number Diff line change
@@ -42,7 +42,16 @@ <h3>{{ talk_as_dict.subtitle }}</h3>
{% if user.is_staff %}
<a href='{% url "admin:conference_talk_change" talk.id %}' class='btn btn-outline-danger'>See in Admin</a>
{% endif %}

</div>

{% if not current_user_is_speaker %}
<form method='POST' action='.'>
{% csrf_token %}
<input name="{{ ADD_CO_SPEAKER }}" type="hidden" value="true">
<button class='btn btn-primary'>Add yourself as co-speaker</button>
</form>
{% endif %}{# current_user_is_speaker #}
</div>

<div class='col-md-4'>
4 changes: 4 additions & 0 deletions tests/test_new_cfp.py
Original file line number Diff line number Diff line change
@@ -302,6 +302,10 @@ def test_preview_page_doesnt_contain_edit_link_if_cfp_is_closed_and_user_is_auth
assert edit_link not in response.content.decode()


def test_preview_can_add_co_speaker(db, client):
...


@mark.django_db
def test_regular_user_cant_access_program_wg_download(user_client):
LOGIN_REQUIRED_302 = 302