I have added a new field in the Registration General Settings area but the field data is not entered in the database.
The field that I created is related to the “Registration fee” (DB field name: base_price) and is named “Registration fee info” (DB field name: base_price_info, data type: text ).
After the modifications I made, I restarted the celery and apache.
I am able to see the new field on the Registration General setting HTML page, but when I enter a value the database is not updated and I get an error when a new registration is created (see below).
I know that I am doing something wrong but I do not know how to move forward.
I would appreciate your help.
This field along with one more field that I added in Billable form (which works fine) are needed so that I can have an itemized cart for PayPal that includes budget information for our financial team.
The following is what I did to add the new field:
-
Manually I added the new field in the following database tables:
Schema: event_registration
Tables: forms, registrations -
Then added the field in the following files:
- ./modules/events/registration/models/registrations.py
added base_price_info field:
- ./modules/events/registration/models/registrations.py
class Registration(db.Model):
# ...
#: PENELOPE - base_price_info base registration fee info
base_price_info = db.Column(
db.String,
nullable=True
)
- ./modules/events/registration/forms.py
Addbase_price_info
in the_price_fields = ('currency', 'base_price', 'base_price_info')
class RegistrationFormForm(IndicoForm):
_price_fields = ('currency', 'base_price', 'base_price_info')
- ./modules/events/registration/util.py
def create_registration(regform, data, invitation=None, management=False, notify_user=True, skip_moderation=None):
user = session.user if session else None
registration = Registration(registration_form=regform, user=get_user_by_email(data['email']),
base_price=regform.base_price, currency=regform.currency, base_price_info=regform.base_price_info)
- ./modules/events/registration/templates/display/_registration_summary_blocks.html
{% if registration.base_price %}
<tr class="regform-done-table-item">
<td class="text-left">
{% trans %}Registration fee{% endtrans %}
</td>
<td></td>
<td class="text-right">
{{ registration.render_base_price() }}
<br>
{{ registration.base_price_info }}
</td>
</tr>
New registration error message in indico.log:
Traceback (most recent call last):
File "/opt/indico/.venv/lib/python2.7/site-packages/flask/app.py", line 1612, in full_dispatch_request
rv = self.dispatch_request()
File "/opt/indico/.venv/lib/python2.7/site-packages/flask/app.py", line 1598, in dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/flask/util.py", line 114, in wrapper
return obj().process()
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/rh.py", line 289, in process
res = self._do_process()
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/web/rh.py", line 259, in _do_process
rv = self._process()
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/modules/events/registration/controllers/management/reglists.py", line 283, in _process
create_registration(self.regform, data, management=True, notify_user=notify_user)
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/core/db/sqlalchemy/util/session.py", line 29, in wrapper
return fn(*args, **kwargs)
File "/opt/indico/.venv/lib/python2.7/site-packages/indico/modules/events/registration/util.py", line 218, in create_registration
base_price=regform.base_price, currency=regform.currency, base_price_info=regform.base_price_info)
AttributeError: 'RegistrationForm' object has no attribute 'base_price_info'