Пример #1
0
def create_corporation(name, description="No description"):
    if Corporation.by_name(name) is not None:
        logging.info("Corporation with name '%s' already exists, skipping" % (name))
        return Corporation.by_name(name)
    logging.info("Create Corporation: %s" % name)
    corp = Corporation(
        name=unicode(name[:32]),
        description=unicode(description[:1024]),
    )
    dbsession.add(corp)
    dbsession.flush()
    return corp
Пример #2
0
def api_admin_refresh_db():
    """
    Refreshes database entities using ESI.

    Returns:
        {'status': 'ok'}

    Error codes:
        Forbidden (403): If logged in user is not an admin
    """
    user_admin_access_check(current_user)
    Corporation.refresh_from_esi()
    Character.refresh_from_esi()
    return jsonify({'status': 'ok'})
Пример #3
0
def update_corporation(corpID, sync=False):
    """
    Updates a corporation from the API. If it's alliance doesn't exist,
    update that as well.
    """
    api = eveapi.EVEAPIConnection(cacheHandler=handler)
    # Encapsulate this in a try block because one corp has a f****d
    # up character that chokes eveapi
    try:
        corpapi = api.corp.CorporationSheet(corporationID=corpID)
    except:
        raise AttributeError("Invalid Corp ID or Corp has malformed data.")

    if corpapi.allianceID:
        try:
            alliance = Alliance.objects.get(id=corpapi.allianceID)
        except:
            # If the alliance doesn't exist, we start a task to add it
            # and terminate this task since the alliance task will call
            # it after creating the alliance object
            if not sync:
                update_alliance.delay(corpapi.allianceID)
                return
            else:
                # Something is waiting and requires the corp object
                # We set alliance to None and kick off the
                # update_alliance task to fix it later
                alliance = None
                update_alliance.delay(corpapi.allianceID)
    else:
        alliance = None

    if Corporation.objects.filter(id=corpID).count():
        # Corp exists, update it
        corp = Corporation.objects.get(id=corpID)
        corp.member_count = corpapi.memberCount
        corp.ticker = corpapi.ticker
        corp.name = corpapi.corporationName
        corp.alliance = alliance
        corp.save()
    else:
        # Corp doesn't exist, create it
        corp = Corporation(id=corpID,
                           member_count=corpapi.memberCount,
                           name=corpapi.corporationName,
                           alliance=alliance)
        corp.save()
    return corp
Пример #4
0
def get_corporation_transactions(corporation_id,
                                 highest_id=None,
                                 current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    response = character.get_op('get_corporations_corporation_id_divisions',
                                corporation_id=corporation_id)
    wallet_division_data = response['wallet']
    divisions = {
        entry['division']: entry.get('name',
                                     'Division {}'.format(entry['division']))
        for entry in wallet_division_data
    }
    return_data = []
    if highest_id is None:
        kwargs = {}
    else:
        kwargs = {'highest_id': highest_id}
    for division_id, division_name in divisions.items():
        entry = {'division_name': division_name}
        transaction_data = character.get_op(
            'get_corporations_corporation_id_wallets_division_transactions',
            corporation_id=corporation_id,
            division=division_id,
            **kwargs,
        )
        entry.update(process_transactions(character, transaction_data))
        return_data.append(entry)
    return {'info': return_data}
Пример #5
0
 def create_box(self):
     ''' Create a box object '''
     form = Form(
         box_name="Enter a box name",
         description="Enter a description",
         difficulty="Select a difficulty",
         corporation_uuid="Please select a corporation",
         game_level="Please select a game level",
     )
     if form.validate(self.request.arguments):
         try:
             game_level = int(self.get_argument('game_level'))
             corp_uuid = self.get_argument('corporation_uuid')
             if Box.by_name(self.get_argument('box_name')) is not None:
                 self.render("admin/create/box.html",
                             errors=["Box name already exists"])
             elif Corporation.by_uuid(corp_uuid) is None:
                 self.render("admin/create/box.html",
                             errors=["Corporation does not exist"])
             elif GameLevel.by_number(game_level) is None:
                 self.render("admin/create/box.html",
                             errors=["Game level does not exist"])
             else:
                 self.__mkbox__()
                 self.redirect('/admin/view/game_objects')
         except ValueError:
             self.render('admin/view/create.html',
                         errors=["Invalid level number"])
     else:
         self.render("admin/create/box.html", errors=form.errors)
Пример #6
0
 def edit_corporations(self):
     ''' Updates corporation object in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing corporation name",
         description="Missing description",
     )
     if form.validate(self.request.arguments):
         corp = Corporation.by_uuid(self.get_argument('uuid'))
         if corp is not None:
             if self.get_argument('name') != corp.name:
                 logging.info("Updated corporation name %s -> %s" % (
                     corp.name,
                     self.get_argument('name'),
                 ))
                 corp.name = unicode(self.get_argument('name'))
             if self.get_argument('description') != corp.description:
                 logging.info("Updated corporation description %s -> %s" % (
                     corp.description,
                     self.get_argument('description'),
                 ))
                 corp.description = unicode(
                     self.get_argument('description'))
             dbsession.add(corp)
             dbsession.flush()
             self.redirect('/admin/view/game_objects')
         else:
             self.render("admin/view/game_objects.html",
                         errors=["Corporation does not exist"])
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Пример #7
0
def visit_corporation_topics(request, gurl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    if request.method == "POST":
        form = NewTopicForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            content = form.cleaned_data['content']
            topic = Topic(title=title)
            turl_number = len(Topic.objects) + 1
            topic.url_number = turl_number
            topic.content = content
            topic.creat_time = datetime.datetime.now()
            topic.is_active = True
            topic.is_locked = False
            topic.is_top = False
            topic.clicks = 0
            topic.update_time = datetime.datetime.now()
            topic.update_author = request.user
            sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
            topic.creator = sccard
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
            
            
    else:
        form = NewTopicForm()
        return render_to_response('corporation/corporation_topics.html', {'form':form, 'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
Пример #8
0
def showactivity(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    activity = Activity.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = activity
                reply.is_active = True
                reply.save()
                activity.clicks = topic.clicks - 1
                activity.save()
                return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/activity/' + str(turl_number) + '/')
            
        
    else:
        reply_form = NewReplyForm()
        activity.clicks = activity.clicks + 1
        activity.save()
        return render_to_response('corporation/activity_corporation.html', {'corporation':corporation, 'current_user':request.user, 'reply_form':reply_form, 'activity':activity, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Пример #9
0
def corporation_manage_department(request,url_number):
    from accounts.models import Student
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        if "user_url_number" in request.POST:
            form_move = MoveMemberForm(request.POST)
            if form_move.is_valid():
                department_name = form_move.cleaned_data['department_name']
                user_url_number = form_move.cleaned_data['user_url_number']
                user = Student.objects(url_number=user_url_number).get()
                sccard = S_C_Card.objects(user=user,corporation=corporation).get()
                corporation.delete_member_from_department(sccard.department,user_url_number)
                corporation.add_member_to_department(department_name,user_url_number)
                return HttpResponseRedirect('')
            
        elif "creat_department" in request.POST:
            form_creat = CreatDepartmentForm(request.POST)
            if form_creat.is_valid():
                department_name = form_creat.cleaned_data['department_name']
                corporation.creat_department(department_name)
                return HttpResponseRedirect('')
            
        elif "delete_department" in request.POST:
            form_delete = DeleteDepartmentForm(request.POST)
            if form_delete.is_valid():
                department_name = form_delete.cleaned_data['department_name']
                corporation.delete_department(department_name)
                return HttpResponseRedirect('')
        
    else:
        form_move = MoveMemberForm()
        form_creat = CreatDepartmentForm()
        form_delete = DeleteDepartmentForm()
        return render_to_response('corporation/corporation_manage_department.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
Пример #10
0
def get_character_corporation_history(character_id, current_user=None):
    character = Character.get(character_id)
    character_application_access_check(current_user, character)
    corporation_list = character.get_op(
        'get_characters_character_id_corporationhistory',
        character_id=character_id,
    )
    for entry in corporation_list:
        entry['is_deleted'] = entry.get('is_deleted', False)
        if entry['is_deleted']:
            entry['corporation_name'] = 'Deleted corp {}'.format(
                entry['corporation_id'])
            entry['alliance_name'] = 'Unknown'
            entry['redlisted'] = []
        else:
            corporation = Corporation.get(entry['corporation_id'])
            entry['corporation_name'] = corporation.name
            if corporation.alliance:
                entry['alliance_name'] = corporation.alliance.name
            else:
                entry['alliance_name'] = None
            redlisted_names = []
            if corporation.is_redlisted:
                redlisted_names.append('corporation_name')
            if corporation.alliance and corporation.alliance.is_redlisted:
                redlisted_names.append('alliance_name')
            if character.is_redlisted:
                redlisted_names.append('character_name')
            entry['redlisted'] = redlisted_names
    return {'info': corporation_list}
Пример #11
0
 def edit_corporations(self):
     ''' Updates corporation object in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing corporation name",
         description="Missing description",
     )
     if form.validate(self.request.arguments):
         corp = Corporation.by_uuid(self.get_argument('uuid'))
         if corp is not None:
             if self.get_argument('name') != corp.name:
                 logging.info("Updated corporation name %s -> %s" %
                     (corp.name, self.get_argument('name'),)
                 )
                 corp.name = unicode(self.get_argument('name'))
             if self.get_argument('description') != corp.description:
                 logging.info("Updated corporation description %s -> %s" %
                     (corp.description, self.get_argument('description'),)
                 )
                 corp.description = unicode(self.get_argument('description'))
             dbsession.add(corp)
             dbsession.flush()
             self.redirect('/admin/view/game_objects')
         else:
             self.render("admin/view/game_objects.html",
                 errors=["Corporation does not exist"]
             )
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Пример #12
0
def visit_corporation_topics(request, gurl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    if request.method == "POST":
        form = NewTopicForm(request.POST)
        if form.is_valid():
            title = form.cleaned_data['title']
            content = form.cleaned_data['content']
            topic = Topic(title=title)
            turl_number = len(Topic.objects) + 1
            topic.url_number = turl_number
            topic.content = content
            topic.creat_time = datetime.datetime.now()
            topic.is_active = True
            topic.is_locked = False
            topic.is_top = False
            topic.clicks = 0
            topic.update_time = datetime.datetime.now()
            topic.update_author = request.user
            sccard = S_C_Card.objects(user=request.user,
                                      corporation=corporation).get()
            topic.creator = sccard
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) +
                                        '/topic/' + str(turl_number) + '/')

    else:
        form = NewTopicForm()
        return render_to_response('corporation/corporation_topics.html', {
            'form': form,
            'corporation': corporation,
            'STATIC_URL': STATIC_URL,
            'current_user': request.user
        },
                                  context_instance=RequestContext(request))
Пример #13
0
 def create_box(self):
     ''' Create a box object '''
     form = Form(
         box_name="Enter a box name",
         description="Enter a description",
         difficulty="Select a difficulty",
         corporation_uuid="Please select a corporation",
         game_level="Please select a game level",
     )
     if form.validate(self.request.arguments):
         try:
             game_level = int(self.get_argument('game_level'))
             corp_uuid = self.get_argument('corporation_uuid')
             if Box.by_name(self.get_argument('box_name')) is not None:
                 self.render("admin/create/box.html",
                     errors=["Box name already exists"]
                 )
             elif Corporation.by_uuid(corp_uuid) is None:
                 self.render("admin/create/box.html",
                     errors=["Corporation does not exist"]
                 )
             elif GameLevel.by_number(game_level) is None:
                 self.render("admin/create/box.html",
                     errors=["Game level does not exist"]
                 )
             else:
                 self.__mkbox__()
                 self.redirect('/admin/view/game_objects')
         except ValueError:
             self.render('admin/view/create.html',
                 errors=["Invalid level number"]
             )
     else:
         self.render("admin/create/box.html", errors=form.errors)
Пример #14
0
def showactivity(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    activity = Activity.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user,
                                          corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = activity
                reply.is_active = True
                reply.save()
                activity.clicks = topic.clicks - 1
                activity.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/activity/' +
                                            str(turl_number) + '/')

    else:
        reply_form = NewReplyForm()
        activity.clicks = activity.clicks + 1
        activity.save()
        return render_to_response('corporation/activity_corporation.html', {
            'corporation': corporation,
            'current_user': request.user,
            'reply_form': reply_form,
            'activity': activity,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Пример #15
0
def corporation_manage_advance(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_manage_advance.html', {
        'corporation': corporation,
        'STATIC_URL': STATIC_URL,
        'current_user': request.user
    },
                              context_instance=RequestContext(request))
Пример #16
0
def update_corporation(corpID, sync=False):
    """
    Updates a corporation from the API. If it's alliance doesn't exist,
    update that as well.
    """
    api = eveapi.EVEAPIConnection(cacheHandler=handler)
    # Encapsulate this in a try block because one corp has a f****d
    # up character that chokes eveapi
    try:
        corpapi = api.corp.CorporationSheet(corporationID=corpID)
    except:
        raise AttributeError("Invalid Corp ID or Corp has malformed data.")

    if corpapi.allianceID:
        try:
            alliance = Alliance.objects.get(id=corpapi.allianceID)
        except:
            # If the alliance doesn't exist, we start a task to add it
            # and terminate this task since the alliance task will call
            # it after creating the alliance object
            if not sync:
                update_alliance.delay(corpapi.allianceID)
                return
            else:
                # Something is waiting and requires the corp object
                # We set alliance to None and kick off the
                # update_alliance task to fix it later
                alliance = None
                update_alliance.delay(corpapi.allianceID)
    else:
        alliance = None

    if Corporation.objects.filter(id=corpID).count():
        # Corp exists, update it
        corp = Corporation.objects.get(id=corpID)
        corp.member_count = corpapi.memberCount
        corp.ticker = corpapi.ticker
        corp.name = corpapi.corporationName
        corp.alliance = alliance
        corp.save()
    else:
        # Corp doesn't exist, create it
        corp = Corporation(id=corpID, member_count=corpapi.memberCount,
                name=corpapi.corporationName, alliance=alliance)
        corp.save()
    return corp
Пример #17
0
def get_corporation_industry(corporation_id, current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    industry_job_data = character.get_op(
        'get_corporations_corporation_id_industry_jobs',
        corporation_id=corporation_id,
    )
    return process_industry(character, industry_job_data)
Пример #18
0
def create_corporation(name, description="No description"):
    print(INFO + "Create corporation: " + bold + name + W)
    corp = Corporation(
        name=unicode(name),
        description=unicode(description),
    )
    dbsession.add(corp)
    dbsession.flush()
    return corp
Пример #19
0
def get_corporation_assets(corporation_id, current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    asset_list = character.get_paged_op(
        'get_corporations_corporation_id_assets',
        corporation_id=corporation_id,
    )
    return process_assets(character, asset_list, corporation_id=corporation_id)
Пример #20
0
def get_character_mail(character_id, last_mail_id=None, current_user=None):
    target_character = Character.get(character_id)
    character_application_access_check(current_user, target_character)
    if last_mail_id:
        kwargs = {'last_mail_id': last_mail_id}
    else:
        kwargs = {}
    mail_list = target_character.get_op('get_characters_character_id_mail',
                                        character_id=character_id,
                                        **kwargs)

    from_ids = set(entry['from'] for entry in mail_list)
    if from_ids:
        character_ids = set()
        corp_ids = set()
        alliance_ids = set()
        mailing_list_ids = set()
        id_set_dict = {
            'character': character_ids,
            'corporation': corp_ids,
            'alliance': alliance_ids,
            'mailing_list': mailing_list_ids,
        }
        name_data = get_from_names(list(from_ids))
        for entry in name_data:
            id_set_dict[entry['category']].add(entry['id'])
        for entry in mail_list:
            for recipient in entry['recipients']:
                id_set_dict[recipient['recipient_type']].add(
                    recipient['recipient_id'])

        characters = Character.get_multi(character_ids)
        corporations = Corporation.get_multi(corp_ids)
        alliances = Alliance.get_multi(alliance_ids)
        all_parties = {}
        all_parties.update(characters)
        all_parties.update(corporations)
        all_parties.update(alliances)
        for id in mailing_list_ids:
            all_parties[id] = MailingList('Mailing List {}'.format(id))

    for entry in mail_list:
        entry['redlisted'] = []
        entry['from_name'] = all_parties[entry['from']].name
        recipients_redlisted = False
        for recipient in entry['recipients']:
            recipient['recipient_name'] = all_parties[
                recipient['recipient_id']].name
            if all_parties[recipient['recipient_id']].is_redlisted:
                recipient['redlisted'] = ['recipient_name']
            else:
                recipient['redlisted'] = []
        if recipients_redlisted:
            entry['redlisted'].append('recipients')
        if all_parties[entry['from']].is_redlisted:
            entry['redlisted'].append('from_name')
    return {'info': mail_list}
Пример #21
0
def topic_inactive(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_topics_inactive.html', {
        'current_user': request.user,
        'url_number': url_number,
        'corporation': corporation,
        'STATIC_URL': STATIC_URL
    },
                              context_instance=RequestContext(request))
Пример #22
0
def initDbForE2e(wipe=True):

    if wipe:
        clearDB()

    # TODO: Id of user a
    admin_id = 123

    db.session.add(
        Character(
            id=admin_id,
            user_id=admin_id,
            name='ADMIN NAME',
            corporation_id=ascee_corp_id,
            refresh_token='YOUR TOKEN HERE',
        ))
    db.session.add(Admin(
        id=admin_id,
        user_id=admin_id,
        name='Billy Admin',
    ))

    # TODO: Id of recruiter user
    recruiter_id = 345

    db.session.add(
        Character(id=recruiter_id,
                  user_id=recruiter_id,
                  name='RECRUITER NAME',
                  corporation_id=ascee_corp_id,
                  refresh_token='YOUR TOKEN HERE'))
    db.session.add(Recruiter(
        id=recruiter_id,
        name='RECRUITER NAME',
    ))

    # TODO: Id of applicant user
    character_id = 234

    db.session.add(
        Character(id=character_id,
                  user_id=character_id,
                  name='APPLICANT NAME',
                  corporation_id=ascee_corp_id,
                  corporation=Corporation(id=ascee_corp_id, name='ASCEE'),
                  refresh_token='YOUR TOKEN HERE'))
    db.session.add(User(
        id=character_id,
        name='APPLICANT NAME',
    ))

    db.session.add(Question(text='How long have you been playing Eve?'))
    db.session.add(Question(text='PVP or PVE? Why?'))

    db.session.add(Application(user_id=character_id))
    db.session.commit()
Пример #23
0
 def create_corporation(self):
     corporation = Corporation(creator_user_id=current_user.id,
                               name=self.name)
     # try:
     db.session.add(corporation)
     db.session.flush()
     admin = AdminAccess(corporation_id=corporation.id). \
         create_creator_admin()
     db.session.commit()
     return corporation, admin
Пример #24
0
 def edit_boxes(self):
     ''' Edit existing boxes in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing box name",
         corporation_uuid="Please select a corporation",
         description="Please enter a description",
         difficulty="Please enter a difficulty",
     )
     if form.validate(self.request.arguments):
         box = Box.by_uuid(self.get_argument('uuid'))
         if box is not None:
             errors = []
             if self.get_argument('name') != box.name:
                 if Box.by_name(self.get_argument('name')) is None:
                     logging.info("Updated box name %s -> %s" % (
                         box.name,
                         self.get_argument('name'),
                     ))
                     box.name = unicode(self.get_argument('name'))
                 else:
                     errors.append("Box name already exists")
             corp = Corporation.by_uuid(
                 self.get_argument('corporation_uuid'))
             if corp is not None and corp.id != box.corporation_id:
                 logging.info("Updated %s's corporation %s -> %s" % (
                     box.name,
                     box.corporation_id,
                     corp.id,
                 ))
                 box.corporation_id = corp.id
             elif corp is None:
                 errors.append("Corporation does not exist")
             if self.get_argument('description') != box.description:
                 logging.info("Updated %s's description %s -> %s" % (
                     box.name,
                     box.description,
                     self.get_argument('description'),
                 ))
                 box.description = unicode(self.get_argument('description'))
             if self.get_argument('difficulty') != box.difficulty:
                 logging.info("Updated %s's difficulty %s -> %s" % (
                     box.name,
                     box.difficulty,
                     self.get_argument('difficulty'),
                 ))
                 box.difficulty = unicode(self.get_argument('difficulty'))
             dbsession.add(box)
             dbsession.flush()
             self.render("admin/view/game_objects.html", errors=errors)
         else:
             self.render("admin/view/game_objects.html",
                         errors=["Box does not exist"])
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Пример #25
0
def creat_corporation(request):
    if request.method == "POST":
        form = CreatCorporationForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            introduction = form.cleaned_data['introduction']
            birthyear = form.cleaned_data['birthyear']
            school = form.cleaned_data['school']
            corporation = Corporation(name=name, introduction=introduction, school=school, birthyear=birthyear, logo=STATIC_URL + 'img/face.png')
            url_number = len(Corporation.objects) + 1
            corporation.url_number = url_number
            corporation.creat_time = datetime.datetime.now()
            if request.FILES:
                path = 'img/corporation/' + str(url_number)
                if not os.path.exists(MEDIA_ROOT + path):
                    os.makedirs(MEDIA_ROOT + path)
                
                img = Image.open(request.FILES['logo'])
                if img.mode == 'RGB':
                    filename = 'logo.jpg'
                    filename_thumbnail = 'thumbnail.jpg'
                elif img.mode == 'P':
                    filename = 'logo.png'
                    filename_thumbnail = 'thumbnail.png'
                filepath = '%s/%s' % (path, filename)
                filepath_thumbnail = '%s/%s' % (path, filename_thumbnail)
                # 获得图像的宽度和高度
                width, height = img.size
                # 计算宽高
                ratio = 1.0 * height / width
                # 计算新的高度
                new_height = int(288 * ratio)
                new_size = (288, new_height)
                # 缩放图像
                if new_height >= 288:
                    thumbnail_size = (0,0,288,288)
                else:
                    thumbnail_size = (0,0,new_height,new_height)
                    
                out = img.resize(new_size, Image.ANTIALIAS)
                thumbnail = out.crop(thumbnail_size)
                thumbnail.save(MEDIA_ROOT + filepath_thumbnail)
                corporation.thumbnail = MEDIA_URL + filepath_thumbnail
                out.save(MEDIA_ROOT + filepath)
                corporation.logo = MEDIA_URL + filepath
                
            corporation.save()
            sccard = S_C_Card(user=request.user, corporation=corporation, is_active=True, is_admin=True,creat_time=datetime.datetime.now())
            sccard.save()
            return HttpResponseRedirect('/corporation/' + str(url_number) + '/')
        
        else:
            return HttpResponseNotFound("出错了。。。。。")
        
    else:
        form = CreatCorporationForm()
        return render_to_response('corporation/creat_corporation.html', {'form':form, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
Пример #26
0
def get_corporation_bookmarks(corporation_id, current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    bookmarks_list = character.get_paged_op(
        'get_corporations_corporation_id_bookmarks',
        corporation_id=corporation_id,
    )
    folder_list = character.get_paged_op(
        'get_corporations_corporation_id_bookmarks_folders',
        corporation_id=corporation_id)
    return process_bookmarks(corporation_id, bookmarks_list, folder_list)
Пример #27
0
 def create_corporation(self):
     ''' Add a new corporation to the database '''
     form = Form(
         corporation_name="Enter a corporation name",
         description="Please enter a description",
     )
     if form.validate(self.request.arguments):
         corp_name = self.get_argument('corporation_name')
         if Corporation.by_name(corp_name) is not None:
             self.render("admin/create/corporation.html",
                         errors=["Name already exists"])
         else:
             corporation = Corporation(
                 name=unicode(corp_name),
                 description=unicode(self.get_argument('description')),
             )
             dbsession.add(corporation)
             dbsession.flush()
             self.redirect('/admin/view/game_objects')
     else:
         self.render("admin/create/corporation.html", errors=form.errors)
Пример #28
0
def corporation_manage_edit(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = ModifyCorporationForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            introduction = form.cleaned_data['introduction']
            corporation.update(set__name=name, set__introduction=introduction)
            if request.FILES:
                path = 'img/corporation/' + str(url_number)
                if not os.path.exists(MEDIA_ROOT + path):
                    os.makedirs(MEDIA_ROOT + path)

                img = Image.open(request.FILES['logo'])
                if img.mode == 'RGB':
                    filename = 'logo.jpg'
                    filename_thumbnail = 'thumbnail.jpg'
                elif img.mode == 'P':
                    filename = 'logo.png'
                    filename_thumbnail = 'thumbnail.png'
                filepath = '%s/%s' % (path, filename)
                filepath_thumbnail = '%s/%s' % (path, filename_thumbnail)
                # 获得图像的宽度和高度
                width, height = img.size
                # 计算宽高
                ratio = 1.0 * height / width
                # 计算新的高度
                new_height = int(288 * ratio)
                new_size = (288, new_height)
                # 缩放图像
                if new_height >= 288:
                    thumbnail_size = (0, 0, 288, 288)
                else:
                    thumbnail_size = (0, 0, new_height, new_height)

                out = img.resize(new_size, Image.ANTIALIAS)
                thumbnail = out.crop(thumbnail_size)
                thumbnail.save(MEDIA_ROOT + filepath_thumbnail)
                corporation.thumbnail = MEDIA_URL + filepath_thumbnail
                out.save(MEDIA_ROOT + filepath)
                corporation.logo = MEDIA_URL + filepath

            corporation.save()
            return HttpResponseRedirect('/corporation/' + str(url_number) +
                                        '/')
    else:
        form = ModifyCorporationForm()
        return render_to_response('corporation/corporation_manage_edit.html', {
            'corporation': corporation,
            'STATIC_URL': STATIC_URL,
            'current_user': request.user
        },
                                  context_instance=RequestContext(request))
Пример #29
0
def ask_quitcorporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = S_S_Card.objects.get_or_create(user=request.user, target__in=corporation.get_user_admin)
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='退社申请', content=content, creator=creator, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number).save()
            return HttpResponse('success')
        
    else:
        return HttpResponse('success')
Пример #30
0
 def __mkbox__(self):
     ''' Creates a box in the database '''
     corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
     level = GameLevel.by_number(int(self.get_argument('game_level')))
     box = Box(
         name=unicode(self.get_argument('box_name')),
         description=unicode(self.get_argument('description')),
         difficulty=unicode(self.get_argument('difficulty')),
         corporation_id=corp.id,
         game_level_id=level.id,
     )
     dbsession.add(box)
     dbsession.flush()
Пример #31
0
 def __mkbox__(self):
     ''' Creates a box in the database '''
     corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
     level = GameLevel.by_number(int(self.get_argument('game_level')))
     box = Box(
         name=unicode(self.get_argument('box_name')),
         description=unicode(self.get_argument('description')),
         difficulty=unicode(self.get_argument('difficulty')),
         corporation_id=corp.id,
         game_level_id=level.id,
     )
     dbsession.add(box)
     dbsession.flush()
Пример #32
0
def get_transaction_party(party_id):
    try:
        character = Character.get(party_id)
        corporation = Corporation.get(character.corporation_id)
        return_dict = {
            'id': party_id,
            'name': character.name,
            'party_type': 'character',
            'corporation_name': corporation.name,
            'corporation_ticker': corporation.ticker,
        }
        return Character.is_redlisted, return_dict
    except IOError:  # change to the correct exception when you know it
        corporation = Corporation.get(party_id)
        return_dict = {
            'id': party_id,
            'name': corporation.name,
            'party_type': 'corporation',
            'corporation_name': corporation.name,
            'corporation_ticker': corporation.ticker,
        }
        return Corporation.is_redlisted, return_dict
Пример #33
0
def get_corporation_market_history(corporation_id, current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    order_list = list(
        character.get_op(
            'get_corporations_corporation_id_orders',
            corporation_id=corporation_id,
        ))
    order_list.extend(
        character.get_paged_op(
            'get_corporations_corporation_id_orders_history',
            corporation_id=corporation_id,
        ))
    return process_market_history(character, order_list)
Пример #34
0
def showtopic(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    if request.method == 'POST':
        if "reply" in request.POST:
            reply_form = NewReplyForm(request.POST)
            if reply_form.is_valid():
                content = reply_form.cleaned_data['content']
                reply = Reply(content=content)
                sccard = S_C_Card.objects(user=request.user,
                                          corporation=corporation).get()
                reply.creator = sccard
                reply.creat_time = datetime.datetime.now()
                reply.target = topic
                reply.is_active = True
                reply.save()
                topic.update_author = request.user
                topic.update_time = datetime.datetime.now()
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/topic/' +
                                            str(turl_number) + '/')

        if "modify" in request.POST:
            modify_form = ModifyTopicForm(request.POST)
            if modify_form.is_valid():
                content = modify_form.cleaned_data['content']
                topic.content = content
                topic.clicks = topic.clicks - 1
                topic.save()
                return HttpResponseRedirect('/corporation/' +
                                            str(gurl_number) + '/topic/' +
                                            str(turl_number) + '/')

    else:
        reply_form = NewReplyForm()
        modify_form = ModifyTopicForm()
        topic.clicks = topic.clicks + 1
        topic.save()
        return render_to_response('corporation/topic_corporation.html', {
            'corporation': corporation,
            'current_user': request.user,
            'reply_form': reply_form,
            'topic': topic,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Пример #35
0
def visit_corporation_structure(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = [a[0] for a in [S_S_Card.objects.get_or_create(user=request.user, target=admin) for admin in corporation.get_user_admin()]]
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='入社申请', content=content, creator=creator, creat_time=datetime.datetime.now(), is_readed=False, url_number=url_number).save()
            S_C_Card(user=request.user,corporation=corporation,is_active=False,is_admin=False).save()
            return HttpResponse('success')
            
            
    else:
        form = NewAskForm()
        return render_to_response('corporation/corporation_structure.html', {'form':form,'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Пример #36
0
 def edit_boxes(self):
     ''' Edit existing boxes in the database '''
     form = Form(
         uuid="Object not selected",
         name="Missing box name",
         corporation_uuid="Please select a corporation",
         description="Please enter a description",
         difficulty="Please enter a difficulty",
     )
     if form.validate(self.request.arguments):
         box = Box.by_uuid(self.get_argument('uuid'))
         if box is not None:
             errors = []
             if self.get_argument('name') != box.name:
                 if Box.by_name(self.get_argument('name')) is None:
                     logging.info("Updated box name %s -> %s" %
                         (box.name, self.get_argument('name'),)
                     )
                     box.name = unicode(self.get_argument('name'))
                 else:
                     errors.append("Box name already exists")
             corp = Corporation.by_uuid(self.get_argument('corporation_uuid'))
             if corp is not None and corp.id != box.corporation_id:
                 logging.info("Updated %s's corporation %s -> %s" %
                     (box.name, box.corporation_id, corp.id,))
                 box.corporation_id = corp.id
             elif corp is None:
                 errors.append("Corporation does not exist")
             if self.get_argument('description') != box.description:
                 logging.info("Updated %s's description %s -> %s" %
                     (box.name, box.description, self.get_argument('description'),)
                 )
                 box.description = unicode(self.get_argument('description'))
             if self.get_argument('difficulty') != box.difficulty:
                 logging.info("Updated %s's difficulty %s -> %s" %
                     (box.name, box.difficulty, self.get_argument('difficulty'),)
                 )
                 box.difficulty = unicode(self.get_argument('difficulty'))
             dbsession.add(box)
             dbsession.flush()
             self.render("admin/view/game_objects.html", errors=errors)
         else:
             self.render("admin/view/game_objects.html",
                 errors=["Box does not exist"]
             )
     else:
         self.render("admin/view/game_objects.html", errors=form.errors)
Пример #37
0
def corporation_manage_edit(request,url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = ModifyCorporationForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            introduction = form.cleaned_data['introduction']
            corporation.update(set__name=name, set__introduction=introduction)
            if request.FILES:
                path = 'img/corporation/' + str(url_number)
                if not os.path.exists(MEDIA_ROOT + path):
                    os.makedirs(MEDIA_ROOT + path)
                
                img = Image.open(request.FILES['logo'])
                if img.mode == 'RGB':
                    filename = 'logo.jpg'
                    filename_thumbnail = 'thumbnail.jpg'
                elif img.mode == 'P':
                    filename = 'logo.png'
                    filename_thumbnail = 'thumbnail.png'
                filepath = '%s/%s' % (path, filename)
                filepath_thumbnail = '%s/%s' % (path, filename_thumbnail)
                # 获得图像的宽度和高度
                width, height = img.size
                # 计算宽高
                ratio = 1.0 * height / width
                # 计算新的高度
                new_height = int(288 * ratio)
                new_size = (288, new_height)
                # 缩放图像
                if new_height >= 288:
                    thumbnail_size = (0,0,288,288)
                else:
                    thumbnail_size = (0,0,new_height,new_height)
                    
                out = img.resize(new_size, Image.ANTIALIAS)
                thumbnail = out.crop(thumbnail_size)
                thumbnail.save(MEDIA_ROOT + filepath_thumbnail)
                corporation.thumbnail = MEDIA_URL + filepath_thumbnail
                out.save(MEDIA_ROOT + filepath)
                corporation.logo = MEDIA_URL + filepath
                
            corporation.save()
            return HttpResponseRedirect('/corporation/' + str(url_number) + '/')
    else:
        form = ModifyCorporationForm()
        return render_to_response('corporation/corporation_manage_edit.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
Пример #38
0
def get_character_summary(character_id, current_user=None):
    character = Character.get(character_id)
    if (character_id != current_user.id):
        character_application_access_check(current_user, character)
    character_data = character.get_op(
        'get_characters_character_id',
        character_id=character_id,
    )
    application = Application.get_for_user(character.user_id)
    if application is not None:
        character_data['current_application_id'] = application.id
        if character_id == current_user.id:
            character_data[
                'current_application_status'] = own_application_status(
                    current_user)['status']
        else:
            character_data[
                'current_application_status'] = get_application_status(
                    application)
    else:
        character_data['current_application_id'] = None
        character_data['current_application_status'] = None
    character_data['security_status'] = character_data.get(
        'security_status', 0.)
    corporation = Corporation.get(character_data['corporation_id'])
    if character.corporation_id != corporation.id:
        character.corporation_id = corporation.id
        db.session.commit()
    character_data['corporation_name'] = corporation.name
    if corporation.alliance is not None:
        character_data['alliance_name'] = corporation.alliance.name
    else:
        character_data['alliance_name'] = None
    character_data['character_name'] = character_data.pop('name')
    character_data['character_id'] = character_id
    redlisted_names = []
    if corporation.is_redlisted:
        redlisted_names.append('corporation_name')
    if corporation.alliance and corporation.alliance.is_redlisted:
        redlisted_names.append('alliance_name')
    if character.is_redlisted:
        redlisted_names.append('character_name')
    character_data['redlisted'] = redlisted_names
    return {'info': character_data}
Пример #39
0
def ask_quitcorporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = S_S_Card.objects.get_or_create(
                user=request.user, target__in=corporation.get_user_admin)
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='退社申请',
                            content=content,
                            creator=creator,
                            creat_time=datetime.datetime.now(),
                            is_readed=False,
                            url_number=url_number).save()
            return HttpResponse('success')

    else:
        return HttpResponse('success')
Пример #40
0
def corporation_manage_department(request, url_number):
    from accounts.models import Student
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        if "user_url_number" in request.POST:
            form_move = MoveMemberForm(request.POST)
            if form_move.is_valid():
                department_name = form_move.cleaned_data['department_name']
                user_url_number = form_move.cleaned_data['user_url_number']
                user = Student.objects(url_number=user_url_number).get()
                sccard = S_C_Card.objects(user=user,
                                          corporation=corporation).get()
                corporation.delete_member_from_department(
                    sccard.department, user_url_number)
                corporation.add_member_to_department(department_name,
                                                     user_url_number)
                return HttpResponseRedirect('')

        elif "creat_department" in request.POST:
            form_creat = CreatDepartmentForm(request.POST)
            if form_creat.is_valid():
                department_name = form_creat.cleaned_data['department_name']
                corporation.creat_department(department_name)
                return HttpResponseRedirect('')

        elif "delete_department" in request.POST:
            form_delete = DeleteDepartmentForm(request.POST)
            if form_delete.is_valid():
                department_name = form_delete.cleaned_data['department_name']
                corporation.delete_department(department_name)
                return HttpResponseRedirect('')

    else:
        form_move = MoveMemberForm()
        form_creat = CreatDepartmentForm()
        form_delete = DeleteDepartmentForm()
        return render_to_response(
            'corporation/corporation_manage_department.html', {
                'corporation': corporation,
                'STATIC_URL': STATIC_URL,
                'current_user': request.user
            },
            context_instance=RequestContext(request))
Пример #41
0
def visit_corporation_activity(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    sccard = S_C_Card.objects(corporation=corporation,user=request.user).get()
    if request.method == "POST":
        form = CreatActivityForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            start_time = form.cleaned_data['start_time']
            finish_time = form.cleaned_data['finish_time']
            place = form.cleaned_data['place']
            max_student = form.cleaned_data['max_student']
            pay = form.cleaned_data['pay']
            detail = form.cleaned_data['detail']
            aurl_number = len(Activity.objects) + 1
            activity = Activity(creator=sccard,url_number=aurl_number,name=name,start_time=start_time,finish_time=finish_time,place=place,max_student=max_student,pay=pay,detail=detail,clicks = 0).save()
            return HttpResponseRedirect('/corporation/' + str(url_number) + '/activity/' + str(aurl_number) + '/')
            
    else:
        form = CreatActivityForm()
        return render_to_response('corporation/corporation_activity.html', {'form':form, 'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Пример #42
0
 def create_corporation(self):
     ''' Add a new corporation to the database '''
     form = Form(
         corporation_name="Enter a corporation name",
         description="Please enter a description",
     )
     if form.validate(self.request.arguments):
         corp_name = self.get_argument('corporation_name')
         if Corporation.by_name(corp_name) is not None:
             self.render("admin/create/corporation.html",
                 errors=["Name already exists"]
             )
         else:
             corporation = Corporation(
                 name=unicode(corp_name),
                 description=unicode(self.get_argument('description')),
             )
             dbsession.add(corporation)
             dbsession.flush()
             self.redirect('/admin/view/game_objects')
     else:
         self.render("admin/create/corporation.html", errors=form.errors)
Пример #43
0
def get_corporation_journal(corporation_id, current_user=None):
    corporation = Corporation.get(corporation_id)
    character = Character.get(corporation.ceo_id)
    character_application_access_check(current_user, character)
    response = character.get_op('get_corporations_corporation_id_divisions',
                                corporation_id=corporation_id)
    wallet_division_data = response['wallet']
    divisions = {
        entry['division']: entry.get('name',
                                     'Division {}'.format(entry['division']))
        for entry in wallet_division_data
    }
    return_data = []
    for division_id, division_name in divisions.items():
        entry = {'division_name': division_name}
        journal_data = character.get_paged_op(
            'get_corporations_corporation_id_wallets_division_journal',
            corporation_id=corporation_id,
            division=division_id,
        )
        entry['info'] = process_journal(character.id, journal_data)['info']
        return_data.append(entry)
    return {'info': return_data}
Пример #44
0
def visit_corporation_activity(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    sccard = S_C_Card.objects(corporation=corporation, user=request.user).get()
    if request.method == "POST":
        form = CreatActivityForm(request.POST)
        if form.is_valid():
            name = form.cleaned_data['name']
            start_time = form.cleaned_data['start_time']
            finish_time = form.cleaned_data['finish_time']
            place = form.cleaned_data['place']
            max_student = form.cleaned_data['max_student']
            pay = form.cleaned_data['pay']
            detail = form.cleaned_data['detail']
            aurl_number = len(Activity.objects) + 1
            activity = Activity(creator=sccard,
                                url_number=aurl_number,
                                name=name,
                                start_time=start_time,
                                finish_time=finish_time,
                                place=place,
                                max_student=max_student,
                                pay=pay,
                                detail=detail,
                                clicks=0).save()
            return HttpResponseRedirect('/corporation/' + str(url_number) +
                                        '/activity/' + str(aurl_number) + '/')

    else:
        form = CreatActivityForm()
        return render_to_response('corporation/corporation_activity.html', {
            'form': form,
            'current_user': request.user,
            'url_number': url_number,
            'corporation': corporation,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Пример #45
0
def visit_corporation_structure(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    if request.method == "POST":
        form = NewAskForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            creator = [
                a[0] for a in [
                    S_S_Card.objects.get_or_create(user=request.user,
                                                   target=admin)
                    for admin in corporation.get_user_admin()
                ]
            ]
            url_number = len(Sitemail.objects) + 1
            mail = Sitemail(title='入社申请',
                            content=content,
                            creator=creator,
                            creat_time=datetime.datetime.now(),
                            is_readed=False,
                            url_number=url_number).save()
            S_C_Card(user=request.user,
                     corporation=corporation,
                     is_active=False,
                     is_admin=False).save()
            return HttpResponse('success')

    else:
        form = NewAskForm()
        return render_to_response('corporation/corporation_structure.html', {
            'form': form,
            'current_user': request.user,
            'url_number': url_number,
            'corporation': corporation,
            'STATIC_URL': STATIC_URL
        },
                                  context_instance=RequestContext(request))
Пример #46
0
def showtopic(request, gurl_number, turl_number):
    corporation = Corporation.objects(url_number=gurl_number).get()
    topic = Topic.objects(url_number=turl_number).get()
    topic.clicks += 1
    topic.save()
    if request.method == 'POST':
        form = NewReplyForm(request.POST)
        if form.is_valid():
            content = form.cleaned_data['content']
            reply = Reply(content=content)
            sccard = S_C_Card.objects(user=request.user, corporation=corporation).get()
            reply.creator = sccard
            reply.creat_time = datetime.datetime.now()
            reply.target = topic
            reply.is_active = True
            reply.save()
            topic.update_author = request.user
            topic.update_time = datetime.datetime.now()
            topic.save()
            return HttpResponseRedirect('/corporation/' + str(gurl_number) + '/topic/' + str(turl_number) + '/')
        
    else:
        form = NewReplyForm()
        return render_to_response('corporation/topic_corporation.html', {'corporation':corporation, 'current_user':request.user, 'form':form, 'topic':topic, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Пример #47
0
def corporation_manage_advance(request,url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_manage_advance.html', {'corporation':corporation, 'STATIC_URL':STATIC_URL, 'current_user':request.user}, context_instance=RequestContext(request))
Пример #48
0
def visit_corporation_activity(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    return render_to_response('corporation/corporation_activity.html', {'current_user':request.user, 'url_number':url_number, 'corporation':corporation, 'STATIC_URL':STATIC_URL}, context_instance=RequestContext(request))
Пример #49
0
def cancle_watch_corporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    corporation.diswatch_corporation(request.user)
    return HttpResponse('success')
Пример #50
0
def kick_out(request,corporation_url_number,user_url_number):
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    corporation.kick_out(user_url_number)
    return HttpResponse('success')
Пример #51
0
def quitcorporation(request, url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    corporation.quitcorporation(request.user)
    return HttpResponse('success')
Пример #52
0
def approve(request,corporation_url_number,user_url_number):
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    corporation.entercorporation(user_url_number)
    return HttpResponse('success')
Пример #53
0
def ask_for_admin(request,url_number):
    corporation = Corporation.objects(url_number=url_number).get()
    corporation.ask_for_admin(request.user)
    return HttpResponse('success')
Пример #54
0
def delete(request,corporation_url_number,user_url_number):
    from accounts.models import Student
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    user = Student.objects(url_number=user_url_number).get()
    S_C_Card.objects(user=user, corporation=corporation).delete()
    return HttpResponse('success')
Пример #55
0
def promote(request,corporation_url_number,user_url_number):
    corporation = Corporation.objects(url_number=corporation_url_number).get()
    corporation.promote(user_url_number)
    return HttpResponse('success')