def create_event(created_by, title, description, all_day=False,<EOL>start_date=None, end_date=None, categories=None, tags=None,<EOL>repeat='<STR_LIT>', end_repeat=None, full=True, utc=False):
if start_date and end_date:<EOL><INDENT>if utc:<EOL><INDENT>val = timezone.utc<EOL><DEDENT>else:<EOL><INDENT>val = timezone.get_default_timezone()<EOL><DEDENT>start_date = timezone.make_aware(datetime.datetime(*start_date), val)<EOL>end_date = timezone.make_aware(datetime.datetime(*end_date), val)<EOL><DEDENT>elif start_date and not end_date or end_date and not start_date:<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>"<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>start_date = timezone.now()<EOL>end_date = timezone.now()<EOL><DEDENT>event = Event.objects.create(<EOL>start_date=start_date,<EOL>end_date=end_date,<EOL>all_day=all_day,<EOL>created_by=created_by,<EOL>title=title,<EOL>description=description,<EOL>repeat=repeat,<EOL>end_repeat=end_repeat<EOL>)<EOL>if categories:<EOL><INDENT>for category in categories:<EOL><INDENT>event.categories.create(title=category)<EOL><DEDENT><DEDENT>if tags:<EOL><INDENT>for tag in tags:<EOL><INDENT>event.tags.create(name=tag)<EOL><DEDENT><DEDENT>if full:<EOL><INDENT>event.full_clean()<EOL>event.save()<EOL><DEDENT>return event<EOL>
A factory method for creating events. If start_date is supplied,
end_date must also be supplied, and they must both be either lists
or tuples e.g. start_date=[2014, 2, 2], end_date=[2014, 2, 3].