Skip to content
This repository has been archived by the owner on Nov 25, 2017. It is now read-only.

Add a field to change event owners #93

Open
schlosser opened this issue Feb 17, 2015 · 0 comments
Open

Add a field to change event owners #93

schlosser opened this issue Feb 17, 2015 · 0 comments

Comments

@schlosser
Copy link
Member

Issue by danrschlosser
Friday Oct 24, 2014 at 06:27 GMT
Originally opened as schlosser/eventum#93


When you write a blog post, you can change the blog post author if you want, and we should have that for events too. This would be the event "owner".

The steps to do this would be:

  1. add a new field on the Event model in app/models/Event.py called owner (similar to the creator field).

  2. add some code in the clean method that ensures that both the owner field is populated, setting owner to creator if owner is None.

  3. add a new SelectField to CreateEventForm (app/forms/CreateEventForm.py) (see app/forms/CreateBlogPostForm.py).

  4. populate it dynamically with the users and set the default to be the current user in app/routes/admin/events.py. Should model after this code in app/routes/admin/posts.py:

    form.author.choices = [
            (str(u.id), u.name + " (You)" if u == g.user else u.name)
            for u in User.objects()]
    form.author.default = str(g.user.id)
  5. Render the field in app/templates/admin/events/create.html to show the select field. See this code in app/templates/admin/posts/create.html:

    <div class="permalink-wrapper small">
        <h6 class="permalink-title">Author:</h6>
        {{ macros.render_field(form.author, required="") }}
    </div>
  6. Edit the dictionary literals in DataBuilder in app/lib/events.py so that converting between forms and events also passes along the value for the owner. Note that the key will just be the fieldname, but the value may be something more like this, taken from app/routes/admin/posts.py :

    post.author = User.objects.get(id=ObjectId(form.author.data))
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant