Add field on signup helper field
This commit is contained in:
parent
e1e98da7d8
commit
c819f88c50
|
@ -18,6 +18,7 @@ def today_alberta_tz():
|
|||
|
||||
class Member(models.Model):
|
||||
user = models.OneToOneField(User, related_name='member', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
signup_helper = models.ForeignKey(User, related_name='signed_up', blank=True, null=True, on_delete=models.SET_NULL)
|
||||
old_email = models.CharField(max_length=254, blank=True, null=True)
|
||||
photo_large = models.CharField(max_length=64, blank=True, null=True)
|
||||
photo_medium = models.CharField(max_length=64, blank=True, null=True)
|
||||
|
|
|
@ -285,6 +285,7 @@ class MemberSerializer(serializers.ModelSerializer):
|
|||
'trotec_cert_date',
|
||||
'is_allowed_entry',
|
||||
'mediawiki_username',
|
||||
'signup_helper',
|
||||
]
|
||||
|
||||
def get_protocoin(self, obj):
|
||||
|
@ -309,6 +310,11 @@ class MemberSerializer(serializers.ModelSerializer):
|
|||
instance.photo_medium = medium
|
||||
instance.photo_large = large
|
||||
|
||||
helper_id = self.initial_data.get('helper_id', None)
|
||||
if helper_id:
|
||||
signup_helper = get_object_or_404(models.Member, id=helper_id)
|
||||
instance.signup_helper = signup_helper.user
|
||||
|
||||
if 'discourse_username' in validated_data:
|
||||
changed = validated_data['discourse_username'] != instance.discourse_username
|
||||
if changed and utils_auth.discourse_is_configured():
|
||||
|
@ -533,12 +539,13 @@ class StorageSpaceSerializer(serializers.ModelSerializer):
|
|||
'id',
|
||||
'shelf_id',
|
||||
'location',
|
||||
'user',
|
||||
]
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
member_id = self.initial_data.get('member_id', None)
|
||||
if member_id:
|
||||
member = get_object_or_404(models.Member, id=self.initial_data['member_id'])
|
||||
member = get_object_or_404(models.Member, id=member_id)
|
||||
validated_data['user'] = member.user
|
||||
else:
|
||||
validated_data['user'] = None
|
||||
|
|
|
@ -4,6 +4,7 @@ import * as loadImage from 'blueimp-load-image';
|
|||
import ReactCrop from 'react-image-crop';
|
||||
import 'react-image-crop/dist/ReactCrop.css';
|
||||
import './light.css';
|
||||
import { MembersDropdown } from './Members.js';
|
||||
import { Button, Container, Form, Grid, Header, Message, Segment } from 'semantic-ui-react';
|
||||
import { requester, randomString } from './utils.js';
|
||||
|
||||
|
@ -300,6 +301,17 @@ export function AccountForm(props) {
|
|||
</>
|
||||
}
|
||||
|
||||
{isSignup && <Form.Field error={error.member_id}>
|
||||
<label>Who helped you sign up? (search)</label>
|
||||
<MembersDropdown
|
||||
token={token}
|
||||
{...makeProps('helper_id')}
|
||||
onChange={handleValues}
|
||||
initial={''}
|
||||
autofocus={''}
|
||||
/>
|
||||
</Form.Field>}
|
||||
|
||||
<Form.Button loading={loading} error={error.non_field_errors}>
|
||||
Submit
|
||||
</Form.Button>
|
||||
|
|
Loading…
Reference in New Issue
Block a user