Commit 2951bb16 authored by Rafal's avatar Rafal

Add init userapi, relationships and userevents

parent 2e6deef0
......@@ -14,3 +14,6 @@ class Command(BaseCommand):
call_command('init_textmessages')
call_command('init_discussions')
call_command('init_events')
call_command('init_relationships')
call_command('init_userevents')
call_command('init_userapi')
\ No newline at end of file
from django.contrib.auth.models import User
from app.Friendship.models import FriendshipRequest
from app.User.models import UserFriendship
__author__ = 'Rafal'
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def add_arguments(self, parser):
parser.add_argument('poll_id', nargs='+', type=int)
def handle(self, *args, **options):
users = [
'admin', 'Antek', 'Rafal', 'Klaudia'
]
admin = User.objects.filter(username=users[0])[0]
Antek = User.objects.filter(username=users[1])[0]
Rafal = User.objects.filter(username=users[2])[0]
Klaudia = User.objects.filter(username=users[3])[0]
print "Create friendships"
print "admin is friend with Antek"
friendship = UserFriendship.objects.create(user=admin, friend=Antek)
friendship.save()
print "admin is friend with Rafal"
friendship = UserFriendship.objects.create(user=admin, friend=Rafal)
friendship.save()
print "Rafal is friend with Klaudia"
friendship = UserFriendship.objects.create(user=Rafal, friend=Klaudia)
friendship.save()
print "Create friendships_requests"
print "Admin send FriendRequest to Klaudia"
new_friendshiprequest = FriendshipRequest.objects.create(user=admin, created_by=Klaudia)
new_friendshiprequest.save()
print "Klaudia send FriendRequest to Antek"
new_friendshiprequest= FriendshipRequest.objects.create(user=Klaudia, created_by=Antek)
new_friendshiprequest.save()
from django.contrib.auth.models import User
from app.API.models import API
from app.Discussion.models import TextMessage, Discussion
from app.Tag.models import Tag
from app.User.models import UserAPI
__author__ = 'Rafal'
from django.core.management.base import BaseCommand
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def add_arguments(self, parser):
parser.add_argument('poll_id', nargs='+', type=int)
def handle(self, *args, **options):
apis = [
['admin', 'Hotele w Krakowie'],
['admin', 'Wypadki w Krakowie'],
['admin', 'Cmenatarze w Krakowie'],
]
print "Creating UserApi"
for api in apis:
print "{0} take {1} API".format(api[0], api[1])
user = User.objects.filter(username=api[0])[0]
api_obj = API.objects.filter(name=api[1])[0]
new_userapi = UserAPI.objects.create(user=user, api=api_obj)
new_userapi.save()
from django.contrib.auth.models import User
from app.Event.models import Event
from app.User.models import UserEvent, UserEventRequest
__author__ = 'Rafal'
from django.core.management.base import BaseCommand, CommandError
class Command(BaseCommand):
help = 'Closes the specified poll for voting'
def add_arguments(self, parser):
parser.add_argument('poll_id', nargs='+', type=int)
def handle(self, *args, **options):
users = [
'admin', 'Antek', 'Rafal', 'Klaudia'
]
admin = User.objects.filter(username=users[0])[0]
Antek = User.objects.filter(username=users[1])[0]
Rafal = User.objects.filter(username=users[2])[0]
Klaudia = User.objects.filter(username=users[3])[0]
print "Creating EventRequests"
event = Event.objects.filter(name="Wyjscie na festiwal UAN")[0]
print "admin is invited by Antek for Wyjscie na festiwal UAN"
eventRequest = UserEventRequest.objects.create(user=admin ,created_by= Antek, event=event)
eventRequest.save()
print "Antek will participe in Wyjscie na festiwal UAN"
userEvent= UserEvent.objects.create(user=Antek, event=event)
userEvent.save()
print "Klaudia will participe in Wyjscie na festiwal UAN"
userEvent= UserEvent.objects.create(user=Klaudia, event=event)
userEvent.save()
print "admin will participe in Wyjscie na festiwal UAN"
userEvent= UserEvent.objects.create(user=admin, event=event)
userEvent.save()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment