当前位置: 首页>>代码示例>>Python>>正文


Python Event.save方法代码示例

本文整理汇总了Python中app.models.Event.save方法的典型用法代码示例。如果您正苦于以下问题:Python Event.save方法的具体用法?Python Event.save怎么用?Python Event.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app.models.Event的用法示例。


在下文中一共展示了Event.save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
def add_event(request):
    if request.method == 'POST':
        event_form = AddEventForm(data=request.POST)

        if event_form.is_valid():
            event = Event()
            event.name =event_form.cleaned_data['name']
            dT = datetime.combine(event_form.cleaned_data['eventDate'], event_form.cleaned_data['eventTime'])
            event.time = dT
            event.no_tickets = event_form.cleaned_data['no_tickets']
            event.price = event_form.cleaned_data['price']
            vname = event_form.cleaned_data['venueName']
            vAddress = event_form.cleaned_data['address']
            vcontact = event_form.cleaned_data['contact']
            vlocation =event_form.cleaned_data['location']

            try:
            	v = Venue.objects.get(name=vname)
            except:
				v = Venue.objects.create(name=vname,address=vAddress,contact=vcontact,location=vlocation)
            event.venue = v
            get_performer = User.objects.get(username=request.user.username)
            performer = Performer.objects.get(performer=get_performer)
            event.performer = performer
            event.save()

            return HttpResponseRedirect('/app/performer_profile/')

        else:
            print event_form.errors
    else:
        event_form = AddEventForm()

    return render(request, 'Gigstop/add_event.html', {'event_form': event_form})
开发者ID:ShinRa26,项目名称:AlphaDragon,代码行数:36,代码来源:views.py

示例2: new

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
def new(request):
	selected_players = None
	
	if request.method == 'POST':
		selected_players = Player.objects.filter(pk__in=request.POST.getlist('players'))
		
		if selected_players.count() == 4:
			event = Event()
			event.save()
			
			for player in selected_players:
				EventResult(player=player, event=event).save()
			
			request.session['event_pk'] = event.pk
			
			return redirect("race-start")
		else:
			messages.error(request, 'Please select exactly 4 players')
	
	# Order player list by race_count
	player_list = Player.objects.order_by('-race_count').all()
	if not selected_players:
		# Auto select most fanatic players
		selected_players = player_list[:4]
	
	return render(request, 'new.html', { 'player_list': player_list, 'selected_players': selected_players })
开发者ID:doryphores,项目名称:django-mk,代码行数:28,代码来源:views.py

示例3: create_single_event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
    def create_single_event(cls, form, creator):
        """Creates a non-recurring Mongoengine and Google Calendar event from
        form data.

        :param form: The WTForms form.
        :type form: :class:`CreateEventForm` or a subclass.
        :param creator: The user that is currently logged in.
        :type creator: :class:`~app.models.User`

        :raises: :class:`GoogleCalendarAPIError` and it's subclasses

        :returns: Response from the Google Calendar API.
        :rtype: dict
        """

        # Generate the event and date data
        event_and_date_data = DataBuilder.event_and_date_data_from_form(
            form,
            creator=creator
        )
        event_and_date_data = cls._remove_none_fields(event_and_date_data)

        event = Event(**event_and_date_data)
        event.save()

        # Return the Google Calendar response
        return gcal_client.create_event(event)
开发者ID:benlowkh,项目名称:adi-website,代码行数:29,代码来源:events.py

示例4: test_One

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
    def test_One(self):

        tperformer = add_performer(bandname ="testband" )
        tvenue = Venue(name ="Stereo")
        tvenue.save()
        my_datetime = timezone.make_aware(datetime.now(), timezone.get_current_timezone())
        event_one = Event(time =my_datetime,media='https://www.youtube.com/watch?v=eh7lp9umG2I',venue=tvenue,performer=tperformer,no_tickets=-1)
        event_one.save()
        self.assertEqual((event_one.no_tickets >=0),True)
开发者ID:ShinRa26,项目名称:AlphaDragon,代码行数:11,代码来源:tests.py

示例5: addevent

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
def addevent():
    form = EventForm(request.form)
    if request.method == 'POST' and form.validate():
        event = Event(name=form.name.data, 
                      intervalMinutes=form.intervalMinutes.data,
                      type=form.type.data, priority=form.priority.data)
        event.save()
        session['current_event'] = event
        return redirect(url_for('views.selecttime'))
    return render_template('addevent.html',session=session, form=form)
开发者ID:dasloss,项目名称:blackholes,代码行数:12,代码来源:views.py

示例6: create_single_event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
    def create_single_event(klass, form, creator):
        """"""
        # Generate the event and date data
        event_and_date_data = DataBuilder.event_and_date_data_from_form(form, creator=creator)
        event_and_date_data = klass._remove_none_fields(event_and_date_data)

        event = Event(**event_and_date_data)
        event.save()

        # Return the Google Calendar response
        return gcal_client.create_event(event)
开发者ID:lifeismotley,项目名称:eventum,代码行数:13,代码来源:events.py

示例7: _make_event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
    def _make_event(cls, e_data, d_data):
        """Create a new :class:`Event` object and save it to Mongoengine.

        The event is created by unpacking non-None fields of ``e_data`` and
        ``d_data`` in the constructor for :class:`Event`.

        :param dict e_data: The event data for this event.
        :param dict d_data: The date data for this event.
        """
        params = cls._remove_none_fields(dict(e_data.items() + d_data.items()))
        event = Event(**params)
        event.save()
        return event
开发者ID:benlowkh,项目名称:adi-website,代码行数:15,代码来源:events.py

示例8: test_create_event_model_with_backwards_dates

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
    def test_create_event_model_with_backwards_dates(self):
        """Test creating an event with the start_datetime after the
        end_datetime.
        """
        # Good dates, bad times
        with self.assertRaises(ValidationError):
            e = Event(title=self.TITLE, creator=self.USER,
                      start_date=self.START.date(),
                      start_time=self.END.time(),
                      end_date=self.END.date(),
                      end_time=self.START.time())
            e.save()

        # Bad dates, good times
        with self.assertRaises(ValidationError):
            e = Event(title=self.TITLE, creator=self.USER,
                      start_date=self.END.date() + timedelta(days=1),
                      start_time=self.START.time(),
                      end_date=self.END.date(),
                      end_time=self.END.time())
            e.save()
开发者ID:Howon,项目名称:eventum,代码行数:23,代码来源:test_events.py

示例9: EventTestCase

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
class EventTestCase(TestCase):
	fixtures = ['test_data',]
	
	def setUp(self):
		self.players = {
			'martin': Player.objects.get(name='Martin'),
			'adam': Player.objects.get(name='Adam'),
			'andy': Player.objects.get(name='Andy'),
			'anton': Player.objects.get(name='Anton'),
		}
	
	def create_event(self):
		self.event = Event()
		self.event.save()
	
	def test_new_event(self):
		"""
		Tests the creation of a new event
		"""
		
		self.create_event()
		
		self.assertEquals(self.event.completed, False)
		self.assertEquals(self.event.players.count(), 0)
		self.assertEquals(self.event.race_count, 0)
		self.assertTrue(self.event.event_date is not None)
		
	def test_add_event_results(self):
		"""
		Tests adding event result records to event
		"""
		
		self.create_event()
		
		for p in self.players:
			EventResult(event=self.event, player=self.players[p]).save()
		
		self.assertEquals(self.event.players.count(), 4)
开发者ID:doryphores,项目名称:django-mk,代码行数:40,代码来源:tests.py

示例10: create

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
def create():
	user = helpers.current_user()
	if not user:
		return abort(403)
	form = CreateEventForm()
	form.category_id.choices = [(ec.id, ec.name) for ec in EventCategory.all()]

	if form.validate_on_submit():
		data = dict(form.data)
		data.pop('image')
		event = Event(**data)
		event.publisher = user
		event.published_on = datetime.now()
		event.save()
		image = form.image.data
		if image:
			path = helpers.save_event_image(event, image)
			event.image_path = path
		event.save(commit=True)
		flash('Event creation successful!', category='success')
		return redirect(url_for('events.show', evt_id=event.id))

	return render_template('events/create.html.j2', form=form)
开发者ID:PeterCP,项目名称:Genera-Flask,代码行数:25,代码来源:events.py

示例11: test_create_event_model_missing_creator

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
 def test_create_event_model_missing_creator(self):
     """Test that creating an Event without a creator fails."""
     with self.assertRaises(ValidationError):
         e = Event(title=self.TITLE)
         e.save()
开发者ID:Howon,项目名称:eventum,代码行数:7,代码来源:test_events.py

示例12: _make_event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
 def _make_event(klass, e_data, d_data):
     """"""
     params = klass._remove_none_fields(dict(e_data.items() + d_data.items()))
     event = Event(**params)
     event.save()
     return event
开发者ID:lifeismotley,项目名称:eventum,代码行数:8,代码来源:events.py

示例13: handle_noargs

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
	def handle_noargs(self, **options):
		cursor = connections['import'].cursor()
		
		# Import players
		
		cursor.execute('SELECT ID, Name FROM Player')
		row = cursor.fetchone()
		players = {}
		while row:
			try:
				player = Player.objects.get(name=row[1])
			except Player.DoesNotExist:
				player = Player(name=row[1])
				player.save()
			
			players[row[0]] = player
			
			row = cursor.fetchone()
		
		cursor.execute('''
			SELECT	EventID, Event.Date, PlayerID, [1st], [2nd], [3rd], [4th]
			FROM	Result INNER JOIN Event on Event.ID = Result.EventID
			WHERE	EventID > 3
			ORDER BY Event.Date ASC
		''')
		
		# Import events
		
		event_id = 0
		event = None
		row = cursor.fetchone()
		
		transaction.commit_unless_managed()
		transaction.enter_transaction_management()
		transaction.managed(True)
		
		try:
			while row:
				if event_id != row[0]:
					event = Event(event_date=row[1])
					try:
						event.save()
						event_id = row[0]
						event_points = 0
						self.stdout.write("Importing event %s\n" % event)
					except IntegrityError:
						# Event already exists, skip it
						self.stdout.write("Skipping event %s (already imported)\n" % row[0])
				
				# Only process result if a saved event exists
				if event.pk is not None:
					result = EventResult(event=event, player=players[row[2]], firsts=row[3], seconds=row[4], thirds=row[5], fourths=row[6])
					result.save()
					event_points += result.points
					
					if event.results.count() == 4:
						if event_points != MAX_EVENT_POINTS:
							# Discard invalid events
							event.delete()
							self.stdout.write("Discarding event %s[%s] (invalid number of points: %s)\n" % (event, event_id, event_points))
						else:
							# Complete event
							event.completed = True
							event.save()
				
				row = cursor.fetchone()
			
		except:
			transaction.rollback()
			transaction.leave_transaction_management()
			self.stdout.write("Unexpected error importing events")
			raise
			return
		
		transaction.commit()
		transaction.leave_transaction_management()
				
开发者ID:doryphores,项目名称:django-mk,代码行数:78,代码来源:import.py

示例14: Group

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
from datetime import datetime

from app.models import Participant, Group, Event, ExpenseType, Weight, Expense

group_a = Group(name="Family A")
group_a.save()
group_b = Group(name="Family B")
group_b.save()
group_c = Group(name="Family C")
group_c.save()

event = Event(name="Holidays in Greece", start_date=datetime.now(), end_date=datetime.now())
event.save()

participant_a = Participant(
    first_name ="John",
    last_name  = "A",
    email      = "[email protected]",
    join_date  = datetime.now(),
    group      = group_a
)
participant_a.save()
participant_a.event = [event]
participant_a.save()

participant_b = Participant(
    first_name ="Jack",
    last_name  = "B",
    email      = "[email protected]",
    join_date  = datetime.now(),
    group      = group_b
开发者ID:nvahlas,项目名称:short-debts-make-long-friends,代码行数:33,代码来源:popuplate_db.py

示例15: Event

# 需要导入模块: from app.models import Event [as 别名]
# 或者: from app.models.Event import save [as 别名]
ncpc = Event(
  name = u"Nordic Collegiate Programming Challenge (NCPC)",
  description = "Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. " \
  "Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.",
  date = date(now.year,now.month,now.day),
  time = time(now.hour, now.minute),
  venue = chalmers,
  website = Link("http://ncpc.example.com"),
  contact_email = Email("[email protected]"),
  contact_phone = PhoneNumber("46 (31) 111222333"),
)
ncpc.add_tag("java")
ncpc.add_tag("smalltalk")
ncpc.add_tag("python")
ncpc.save()

nordic_python = Event(
  name = u"Nordic Python Conference",
  description = "Lorem ipsum dolor sit amet",
  date = date(just_before.year,just_before.month,just_before.day),
  time = time(just_before.hour, just_before.minute),
  venue = kth,
  website = None,
  contact_email = None,
  contact_phone = None,
)
nordic_python.add_tag("python")
nordic_python.save()

foobar = Event(
开发者ID:kskrishnasangeeth,项目名称:techfeed,代码行数:32,代码来源:fixtures.py


注:本文中的app.models.Event.save方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。