Beispiel #1
0
def campaign_new():
    form = CampaignForm()
    if request.method == 'GET' and g.board:
        form.boards.data = [g.board]
    if form.validate_on_submit():
        campaign = Campaign(user=g.user)
        form.populate_obj(campaign)
        campaign.name = suuid(
        )  # Use a random name since it's also used in user action submit forms
        db.session.add(campaign)
        db.session.commit()
        flash(u"Created a campaign", 'success')
        return render_redirect(url_for('campaign_view',
                                       campaign=campaign.name),
                               code=303)

    return render_form(
        form=form,
        title=u"Create a campaign…",
        submit="Next",
        message=
        u"Campaigns appear around the job board and provide a call to action for users",
        formid="campaign_new",
        cancel_url=url_for('campaign_list'),
        ajax=False)
Beispiel #2
0
 def test_suuid(self):
     """
     Test the ShortUUID functions
     """
     s1 = suuid()
     self.assertEqual(len(s1), 22)
     u1 = suuid2uuid(s1)
     self.assertIsInstance(u1, uuid.UUID)
     self.assertEqual(u1.version, 4)  # ShortUUID uses v4 UUIDs by default
     s2 = uuid2suuid(u1)
     self.assertEqual(s1, s2)
Beispiel #3
0
 def test_suuid(self):
     """
     Test the ShortUUID functions
     """
     s1 = suuid()
     self.assertEqual(len(s1), 22)
     u1 = suuid2uuid(s1)
     self.assertIsInstance(u1, uuid.UUID)
     self.assertEqual(u1.version, 4)  # ShortUUID uses v4 UUIDs by default
     s2 = uuid2suuid(u1)
     self.assertEqual(s1, s2)
Beispiel #4
0
def campaign_action_new(campaign):
    form = CampaignActionForm()
    if request.method == 'GET':
        form.seq.data = max([a.seq for a in campaign.actions] or [0]) + 1
    if form.validate_on_submit():
        action = CampaignAction(campaign=campaign)
        db.session.add(action)
        form.populate_obj(action)
        action.name = suuid()  # Use a random name since it needs to be permanent
        db.session.commit()
        flash(u"Added campaign action ‘%s’" % action.title, 'interactive')
        return redirect(url_for('campaign_view', campaign=campaign.name), code=303)

    return render_form(form=form, title=u"Add a new campaign action…", submit="Save",
        formid="campaign_action_new", cancel_url=url_for('campaign_view', campaign=campaign.name), ajax=False)
Beispiel #5
0
    def new(self):
        self.message = u"Campaigns appear around the job board and provide a call to action for users"
        form = CampaignForm()
        if request.method == 'GET' and g.board:
            form.boards.data = [g.board]
        if form.validate_on_submit():
            campaign = Campaign(user=g.user)
            form.populate_obj(campaign)
            campaign.name = suuid()  # Use a random name since it's also used in user action submit forms
            db.session.add(campaign)
            db.session.commit()
            flash(u"Created a campaign", 'success')
            return render_redirect(campaign.url_for(), code=303)

        return render_form(form=form, title=u"Create a campaign…", submit="Next",
            formid="campaign_new", cancel_url=url_for(self.list_current.endpoint), ajax=False)
Beispiel #6
0
    def action_new(self):
        self.form_header = Markup(render_template('campaign_action_edit_header.html.jinja2', campaign=self.obj))
        form = CampaignActionForm()
        if request.method == 'GET':
            form.seq.data = max([a.seq for a in self.obj.actions] or [0]) + 1
        if form.validate_on_submit():
            action = CampaignAction(campaign=self.obj)
            db.session.add(action)
            form.populate_obj(action)
            action.name = suuid()  # Use a random name since it needs to be permanent
            db.session.commit()
            flash(u"Added campaign action ‘%s’" % action.title, 'interactive')
            return redirect(self.obj.url_for(), code=303)

        return render_form(form=form, title=u"Add a new campaign action…", submit="Save",
            formid="campaign_action_new", cancel_url=self.obj.url_for(), ajax=False)
Beispiel #7
0
    def action_new(self):
        self.form_header = Markup(render_template('campaign_action_edit_header.html.jinja2', campaign=self.obj))
        form = CampaignActionForm()
        if request.method == 'GET':
            form.seq.data = max([a.seq for a in self.obj.actions] or [0]) + 1
        if form.validate_on_submit():
            action = CampaignAction(campaign=self.obj)
            db.session.add(action)
            form.populate_obj(action)
            action.name = suuid()  # Use a random name since it needs to be permanent
            db.session.commit()
            flash(u"Added campaign action ‘%s’" % action.title, 'interactive')
            return redirect(self.obj.url_for(), code=303)

        return render_form(form=form, title=u"Add a new campaign action…", submit="Save",
            formid="campaign_action_new", cancel_url=self.obj.url_for(), ajax=False)