Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- +class AddAccountForm(forms.ModelForm):
- + """
- + Add account form for TransCosmos
- + """
- + TERM_CHOICES = (
- + ('6', _('6-month')),
- + ('12', _('12-month'))
- + )
- + PRICING_TIERS = (
- + ('1', _('Tier 1')),
- + ('2', _('Tier 2')),
- + ('3', _('Tier 3'))
- + )
- + name = forms.CharField()
- + description = forms.CharField(widget=forms.Textarea)
- + start_date = forms.DateField()
- + license_term = forms.ChoiceField(widget=forms.RadioSelect, choices=TERM_CHOICES)
- + pricing_tier = forms.ChoiceField(widget=forms.Select(), choices=PRICING_TIERS)
- +
- + def __init__(self, *args, **kwargs):
- + if 'branding' in kwargs:
- + del kwargs['branding']
- +
- + super(AddAccountForm, self).__init__(*args, **kwargs)
- +
- + class Meta:
- + model = Org
- + fields = '__all__'
- +
- +
- class OrgGrantForm(forms.ModelForm):
- first_name = forms.CharField(help_text=_("The first name of the organization administrator"))
- last_name = forms.CharField(help_text=_("Your last name of the organization administrator"))
- @@ -590,7 +620,7 @@ class OrgCRUDL(SmartCRUDL):
- actions = ('signup', 'home', 'channels', 'webhook', 'edit', 'join', 'grant', 'create_login', 'choose',
- 'manage_accounts', 'manage', 'create','update', 'country', 'languages', 'clear_cache', 'download',
- 'twilio_connect', 'twilio_account', 'nexmo_configuration', 'nexmo_account', 'nexmo_connect', 'kik_connect',
- - 'export', 'import', 'plivo_connect', 'service', 'surveyor', 'opening_hours')
- + 'export', 'import', 'plivo_connect', 'service', 'surveyor', 'opening_hours', 'add_account')
- model = Org
- @@ -2214,6 +2244,32 @@ class OrgCRUDL(SmartCRUDL):
- return response
- + class AddAccount(Grant):
- + title = _("Add Account")
- + form_class = AddAccountForm
- + permission = None
- + success_message = ''
- + submit_button_name = _("Create Account")
- + fields = ('name', 'description', 'start_date', 'pricing_tier', 'license_term')
- +
- + def get_success_url(self):
- + return "%s?start" % reverse('public.public_welcome')
- +
- + def get_welcome_size(self):
- + welcome_topup_size = self.request.branding.get('welcome_topup', WELCOME_TOPUP_SIZE)
- + return welcome_topup_size
- +
- + def post_save(self, obj):
- + obj = super(OrgCRUDL.AddAccount, self).post_save(obj)
- + self.request.session['org_id'] = obj.pk
- +
- + user = authenticate(username=self.user.username, password=self.form.cleaned_data['password'])
- + login(self.request, user)
- + analytics.track(self.request.user.username, 'temba.org_signup', dict(org=obj.name))
- +
- + return obj
- +
- +
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement