Manage requests.  Display a list of request types with links to edit them.
    Also display a link to add a new request type.  Restricted to presidents and superadmins.
357646
def manage_request_types_view(request):
    ''' 
    '''
    request_types = RequestType.objects.all()
    return render_to_response('manage_request_types.html', {
        'page_name': "Admin - Manage Request Types",
        'request_types': request_types
        }, context_instance=RequestContext(request))
725878
def _to_edit_kind(self, post_uid):
        '''
        
        '''
        if self.userinfo and self.userinfo.role[1] >= '3':
            pass
        else:
            self.redirect('/')
        postinfo = MPost.get_by_uid(post_uid, )
        json_cnt = json.dumps(postinfo.extinfo, indent=True)
        kwd = {}
        self.render('man_info/post_kind.html',
                    postinfo=postinfo,
                    sig_dic=router_post,
                    userinfo=self.userinfo,
                    json_cnt=json_cnt,
                    kwd=kwd)
1108517
def update_admin_page_links
      admin_page_links = []
      Pwb::Link.ordered_visible_admin.each do |link|
        admin_page_links.push link.as_json
      end
      configuration["admin_page_links"] = admin_page_links
      save!
      admin_page_links
    end
1370956
def get_actions(self, request):
        
        actions = super(EntryAdmin, self).get_actions(request)
        if not actions:
            return actions
        if (not request.user.has_perm('zinnia.can_change_author') or
                not request.user.has_perm('zinnia.can_view_all')):
            del actions['make_mine']
        if not request.user.has_perm('zinnia.can_change_status'):
            del actions['make_hidden']
            del actions['make_published']
        if not settings.PING_DIRECTORIES:
            del actions['ping_directories']

        return actions
776864
def add_event_view(request):
    
    is_events_admin = request.user.has_admin_permission('events')
    if not is_events_admin:
        return redirect("request_event")

    if request.method == "POST":
        form = EventForm(data=request.POST, all_groups=request.user.has_admin_permission('groups'))
        logger.debug(form)
        if form.is_valid():
            obj = form.save()
            obj.user = request.user
            # SAFE HTML
            obj.description = safe_html(obj.description)

            # auto-approve if admin
            obj.approved = True
            obj.approved_by = request.user
            messages.success(request, "Because you are an administrator, this event was auto-approved.")
            obj.created_hook(request)

            obj.save()
            return redirect("events")
        else:
            messages.error(request, "Error adding event.")
    else:
        form = EventForm(all_groups=request.user.has_admin_permission('groups'))
    context = {"form": form, "action": "add", "action_title": "Add" if is_events_admin else "Submit", "is_events_admin": is_events_admin}
    return render(request, "events/add_modify.html", context)
1059050
def admin_url_params(request, params=None):
    
    params = params or {}
    if popup_status(request):
        params[IS_POPUP_VAR] = '1'
    pick_type = popup_pick_type(request)
    if pick_type:
        params['_pick'] = pick_type
    return params
35793
public function editAction()
    {
        $form = new \CmsAdmin\Form\CategoryType(new \Cms\Orm\CmsCategoryTypeRecord($this->id));
        if ($form->isSaved()) {
            $this->getMessenger()->addMessage('messenger.categoryTypeAttribute.categoryType.saved', true);
            $this->getResponse()->redirect('cmsAdmin', 'categoryType');
        }
        $this->view->categoryTypeForm = $form;
    }
408789
def edit_link(obj, options = {})
      if policy(obj).edit?
        url = polymorphic_url([:edit] + Array(obj))
        action_link('Edit', url, 'pencil', options)
      end
    end
860050
def edit_request_type_view(request, typeName):
    ''' 
    '''
    requestType = get_object_or_404(RequestType, url_name=typeName)
    form = RequestTypeForm(
        request.POST or None,
        instance=requestType,
        )
    if form.is_valid():
        rtype = form.save()
        messages.add_message(request, messages.SUCCESS,
                             MESSAGES['REQUEST_TYPE_SAVED'].format(typeName=rtype.name))
        return HttpResponseRedirect(reverse('managers:manage_request_types'))
    return render_to_response('edit_request_type.html', {
        'page_name': "Admin - Edit Request Type",
        'request_types': RequestType.objects.all(),
        'form': form,
        'requestType': requestType,
        }, context_instance=RequestContext(request))
953049
def add_view(self, request, form_url='', extra_context=None):
        """"""
        model = self.model
        opts = model._meta

        if not self.has_add_permission(request):
            raise PermissionDenied

        ModelForm = self.get_form(request)
        formsets = []

        if request.method == 'POST':
            form = ModelForm(request.POST, request.FILES)

            if form.is_valid():
                new_object = self.save_form(request, form, change=False)
                form_validated = True
            else:
                form_validated = False
                new_object = self.model()

            prefixes = {}

            for FormSet, inline in zip(self.get_formsets(request),
                                       self.get_inline_instances(request)):
                prefix = FormSet.get_default_prefix()
                prefixes[prefix] = prefixes.get(prefix, 0) + 1

                if prefixes[prefix] != 1:
                    prefix = "{0}-{1}".format(prefix, prefixes[prefix])

                formset = FormSet(data=request.POST, files=request.FILES,
                                  instance=new_object,
                                  save_as_new="_saveasnew" in request.POST,
                                  prefix=prefix, queryset=inline.queryset(request))

                formsets.append(formset)

                for inline in self.get_inline_instances(request):
                    # If this is the inline that matches this formset, and
                    # we have some nested inlines to deal with, then we need
                    # to get the relevant formset for each of the forms in
                    # the current formset.
                    if inline.inlines and inline.model == formset.model:
                        for nested in inline.inline_instances:
                            for the_form in formset.forms:
                                InlineFormSet = nested.get_formset(request, the_form.instance)
                                prefix = "{0}-{1}".format(the_form.prefix,
                                                          InlineFormSet.get_default_prefix())
                                formsets.append(InlineFormSet(request.POST, request.FILES,
                                                              instance=the_form.instance,
                                                              prefix=prefix))
            if all_valid(formsets) and form_validated:
                self.save_model(request, new_object, form, change=False)
                form.save_m2m()

                for formset in formsets:
                    self.save_formset(request, form, formset, change=False)

                self.log_addition(request, new_object)

                return self.response_add(request, new_object)
        else:
            # Prepare the dict of initial data from the request.
            # We have to special-case M2Ms as a list of comma-separated PKs.
            initial = dict(request.GET.items())

            for k in initial:
                try:
                    f = opts.get_field(k)
                except models.FieldDoesNotExist:
                    continue

                if isinstance(f, models.ManyToManyField):
                    initial[k] = initial[k].split(",")

            form = ModelForm(initial=initial)
            prefixes = {}

            for FormSet, inline in zip(self.get_formsets(request),
                                       self.get_inline_instances(request)):
                prefix = FormSet.get_default_prefix()
                prefixes[prefix] = prefixes.get(prefix, 0) + 1

                if prefixes[prefix] != 1:
                    prefix = "{0}-{1}".format(prefix, prefixes[prefix])

                formset = FormSet(instance=self.model(), prefix=prefix,
                                  queryset=inline.queryset(request))
                formsets.append(formset)

        adminForm = helpers.AdminForm(form, list(self.get_fieldsets(request)),
                                      self.prepopulated_fields, self.get_readonly_fields(request),
                                      model_admin=self)

        media = self.media + adminForm.media
        inline_admin_formsets = []

        for inline, formset in zip(self.get_inline_instances(request), formsets):
            fieldsets = list(inline.get_fieldsets(request))
            readonly = list(inline.get_readonly_fields(request))
            inline_admin_formset = helpers.InlineAdminFormSet(inline, formset,
                                                              fieldsets, readonly,
                                                              model_admin=self)
            if inline.inlines:
                for form in formset.forms:
                    if form.instance.pk:
                        instance = form.instance
                    else:
                        instance = None

                    form.inlines = inline.get_inlines(request, instance, prefix=form.prefix)

                inline_admin_formset.inlines = inline.get_inlines(request)

            inline_admin_formsets.append(inline_admin_formset)
            media = media + inline_admin_formset.media

        context = {
            'title': _('Add %s') % force_unicode(opts.verbose_name),
            'adminform': adminForm,
            'is_popup': "_popup" in request.REQUEST,
            'show_delete': False,
            'media': mark_safe(media),
            'inline_admin_formsets': inline_admin_formsets,
            'errors': helpers.AdminErrorList(form, formsets),
            'app_label': opts.app_label,
        }

        context.update(extra_context or {})

        return self.render_change_form(request, context, form_url=form_url, add=True)
812226
def workflow_add_types(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
1281415
def perform_request(self, request_type, *args, **kwargs):
        
        # create a request
        req = api_request(request_type, *args, **kwargs)

        # send it
        res = self.send_request(req)

        return res
812946
def record_add_types(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/addTypes' % object_id, input_params, always_retry=always_retry, **kwargs)
1112181
def edit
      @admin = current_admin.id == params[:id].to_i ? @current_admin : Admin.find(params[:id])

      # add breadcrumb and set title
      set_title(I18n.t("controllers.admin.administrators.edit.title", username: @admin.username))
      add_breadcrumb I18n.t("controllers.admin.administrators.edit.breadcrumb")

      # action for the form as both edit/new are using the same form.
      @action = 'update'

      # only allowed to edit the super user if you are the super user.
      if @admin.overlord == 'Y' && @admin.id != session[:admin_id]

        respond_to do |format|

          flash[:error] = I18n.t("controllers.admin.administrators.edit.flash.error")
          format.html { redirect_to admin_administrators_path }

        end

      end
    end
357739
def add_view_permissions(sender, verbosity, **kwargs):
    
    from django.contrib.contenttypes.models import ContentType
    from django.contrib.auth.models import Permission

    for content_type in ContentType.objects.all():
        codename = "view_%s" % content_type.model

        _, created = Permission.objects \
            .get_or_create(content_type=content_type,
                           codename=codename,
                           defaults={'name': 'Can view %s' % content_type.name})
        if created and verbosity >= 1:
            print('Added view permission for %s' % content_type.name)
1210503
def _add_version_to_request(self, url, headers, version):
        """"""
        if self._has_capability(SERVER_REQUIRES_VERSION_HEADER):
            new_headers = headers.copy()
            new_headers['Last-Modified'] = email.utils.formatdate(version)
            return url, new_headers
        else:
            url_params = {
                'last_modified': email.utils.formatdate(version)
            }
            new_url = url + "?" + urlencode(url_params)
            return new_url, headers
1331868
def add_view(self, request, **kwargs):
        
        try:
            return super(ClonedRepoAdmin, self).add_view(request, **kwargs)
        except ValidationError:
            # Rerender the form, having messaged the user.
            return redirect(request.path)