django.contrib.messages.info - python examples

Here are the examples of the python api django.contrib.messages.info taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

95 Examples 7

3 View Complete Implementation : processinstance.py
Copyright MIT License
Author : vicalloy
def edit(request, pk):
    instance = get_object_or_404(ProcessInstance, pk=pk)
    wf_code = instance.process.code
    views = import_wf_views(wf_code)
    if not can_edit_wf(instance, request.user):
        messages.info(request, 'No permission: %s' % instance)
        return redirect(reverse('wf_my_wf'))
    return views.edit(request, instance.content_object)

3 View Complete Implementation : admin.py
Copyright MIT License
Author : morlandi
    def run(self, object_id, request):
        try:
            obj = get_object_by_uuid_or_404(self.model, object_id)
            job = obj.run(is_async=True, request=request)
            messages.info(request, _('Task "%s" scheduled for execution (job: "%s")') % (object_id, job.get_id()))
        except Exception as e:
            messages.error(request, str(e))
            if settings.DEBUG:
                messages.warning(request, mark_safe('<br />'.join(traceback.format_exc().split('\n'))))
        info = self.model._meta.app_label, self.model._meta.model_name
        return HttpResponseRedirect(reverse("admin:%s_%s_changelist" % info))

3 View Complete Implementation : registration.py
Copyright Apache License 2.0
Author : Integreat
def logout(request):
    """View to provide logout functionality
    Args:
            request: Object representing the user call
    Returns:
            HttpResponseRedirect: Redirect to the login page after logout
    """

    django_logout(request)
    messages.info(request, _('You have been successfully logged off.'))
    return HttpResponseRedirect(reverse('login'))

3 View Complete Implementation : task_template.py
Copyright MIT License
Author : telminov
    def get(self, request, *args, **kwargs):
        task_template = self.get_object()
        task_hosts = task_template.hosts.all()
        user_hosts = task_hosts.filter(users__in=[self.request.user])

        if user_hosts.count() == task_hosts.count():
            in_progress_tasks = task_template.tasks.filter(status__in=consts.RUN_STATUSES)
            if in_progress_tasks.exists():
                messages.info(self.request, 'The same task was not started. You have been redirected to a running task.')
                task = in_progress_tasks.last()
            else:
                task = task_template.create_task(self.request.user)

            return redirect(reverse('task_log', kwargs={'pk': task.id}))
        else:
            messages.info(self.request, 'This user does not have an acces to this host')
            return redirect(reverse('task_search'))

3 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : netbox-community
    def get(self, request):

        # Log out the user
        auth_logout(request)
        messages.info(request, "You have logged out.")

        # Delete session key cookie (if set) upon logout
        response = HttpResponseRedirect(reverse('home'))
        response.delete_cookie('session_key')

        return response

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def publish_module(self):
        module = self.get_object()
        if not module.is_draft:
            messages.info(self.request, _('Module is already added'))
            return

        module.is_draft = False
        module.save()

        signals.module_published.send(sender=None,
                                      module=module,
                                      user=self.request.user)

        messages.success(self.request,
                         _('Module successfully added.'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : lyk2016-python
def register(request):
	form = RegistrationForm()

	if request.method == 'POST':
		form = RegistrationForm(request.POST)

		if form.is_valid():
			form.save()

			messages.info(
				request,
				'Kayıt başarılı. Şimdi login olabilirsiniz.'
			)

			return redirect('login')

	return render(request, 'register.html', {
		'form': form,
	})

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : cldrn
def clear_logs(request):
    """Clear admin activity logs if user has permissions"""

    if not request.user.is_authenticated(): # should be applied to anything under /console
        return redirect('login')

    if request.user.has_perm('admin.delete_logentry'):
        LogEntry.objects.all().filter(user__pk=request.user.id).delete()
        messages.info(request, 'Successfully cleared admin activity logs.', fail_silently=True)
    else:
        messages.warning(request, 'Unable to clear the admin activity logs.', fail_silently=True)

    return redirect('admin:index')

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : mwillsey
@login_required
def unequip_item(request, item_type):
    user = request.user.cb_user
    if request.method == 'POST':
        if item_type == 'hat':
            user.unequip_hat()
            messages.info(request, "Hat unequipped.")
        elif item_type == 'satle':
            user.unequip_satle()
            messages.info(request, "satle unequipped.")

    return redirect('inventory')

3 View Complete Implementation : signals.py
Copyright MIT License
Author : line
@run_once(trigger_write_config)
def _trigger_write_config(signal, **kwargs):
    targets = [server.host for server in models.Prometheus.objects.all()]
    for target in targets:
        logger.info('Queueing write_config on %s', target)
        tasks.write_config.apply_async(queue=target)
    if 'request' in kwargs:
        messages.info(kwargs['request'], 'Updating config on {}'.format(targets))
    return True

3 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : respawner
    def get(self, request):
        if is_user_logged_in(request):
            auth_logout(request)
            messages.info(request, "You have logged out.")

        return redirect("home")

3 View Complete Implementation : account.py
Copyright MIT License
Author : openstates
@login_required
def profile(request):
    primary = request.user.emailaddress_set.get(primary=True)

    # only get their key if the email is verified
    key = None
    if primary.verified:
        try:
            key = Key.objects.get(email=primary.email)
        except Key.DoesNotExist:
            past

    messages.info(
        request,
        "Accounts are currently a beta feature, more functionality is coming soon!",
    )
    return render(
        request, "account/profile.html", {"primary_email": primary, "key": key}
    )

3 View Complete Implementation : views.py
Copyright MIT License
Author : line
    def post(self, request, pk, source):
        project = get_object_or_404(models.Project, id=pk)
        farm, created = models.Farm.objects.get_or_create(
            name=request.POST['farm'],
            source=source,
        )
        if created:
            logger.info('Importing %s from %s', farm.name, source)
            farm.refresh()
            messages.info(request, 'Refreshed hosts')
        project.farm = farm
        project.save()
        return HttpResponseRedirect(reverse('project-detail', args=[project.id]))

3 View Complete Implementation : forms.py
Copyright MIT License
Author : vicalloy
    def save_new_process(self, request, wf_code):
        submit = request.POST.get('act_submit')
        act_name = request.POST.get('act_submit') or 'Save'
        obj = self.save(commit=False)
        obj.created_by = request.user
        obj.create_pinstance(wf_code, submit)
        self.save_m2m()
        # Other action
        messages.info(request, 'Success %s: %s' % (act_name, obj, ))
        return obj

3 View Complete Implementation : views.py
Copyright Creative Commons Zero v1.0 Universal
Author : gileno
    def get(self, request, *args, **kwargs):
        session_key = request.session.session_key
        if session_key and Carsatem.objects.filter(cart_key=session_key).exists():
            cart_items = Carsatem.objects.filter(cart_key=session_key)
            order = Order.objects.create_order(
                user=request.user, cart_items=cart_items
            )
            cart_items.delete()
        else:
            messages.info(request, 'Não há itens no carrinho de compras')
            return redirect('checkout:cart_item')
        response = super(CheckoutView, self).get(request, *args, **kwargs)
        response.context_data['order'] = order
        return response

3 View Complete Implementation : transition.py
Copyright MIT License
Author : vicalloy
    def get_task_list(self, request):
        task_list = []
        for task in super().get_task_list(request):
            if task.node.can_reject:
                task_list.append(task)
            else:
                messages.info(
                    request,
                    """You can't reject process "%s" """ %
                    (
                        task.instance.no,
                    )
                )
        return task_list

3 View Complete Implementation : admin.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : escaped
    def toggle_publish(self, request, obj, parent_obj=None):
        if obj.status == Article.DRAFT:
            obj.status = Article.PUBLISHED
        else:
            obj.status = Article.DRAFT

        obj.save()
        status = 'unpublished' if obj.status == Article.DRAFT else 'published'
        messages.info(request, _("Article {}.".format(status)))

3 View Complete Implementation : views.py
Copyright MIT License
Author : lyk2016-python
def login(request):
	form = LoginForm()

	if request.method == 'POST':
		form = LoginForm(request.POST)

		if form.is_valid():
			auth_login(request, form.user)
			messages.info(
				request,
				'Giriş yaptınız.'
			)

	return render(request, 'login.html', {
		'form': form
	})

3 View Complete Implementation : views.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
@facebook_required(scope='publish_actions')
def open_graph_beta(request):
    '''
    Simple example on how to do open graph postings
    '''
    fb = get_persistent_graph(request)
    ensaty_url = 'http://www.fashiolista.com/item/2081202/'
    result = fb.set('me/fashiolista:love', item=ensaty_url)
    messages.info(request, 'Frictionless sharing to open graph beta action fashiolista:love with item_url %s, this url contains open graph data which Facebook scrapes' % ensaty_url)

3 View Complete Implementation : admin.py
Copyright MIT License
Author : morlandi
    def repeat(self, request, object_id):
        try:
            source_obj = get_object_by_uuid_or_404(self.model, object_id)
            clone = source_obj.clone(request)
            #messages.info(request, _('Task "%s" cloned to "%s"') % (source_obj.id, clone.id))
            job = clone.run(is_async=True, request=request)
            messages.info(request, _('Task "%s" scheduled for execution (job: "%s")') % (clone.id, job.get_id()))
        except Exception as e:
            messages.error(request, str(e))
            if settings.DEBUG:
                messages.warning(request, mark_safe('<br />'.join(traceback.format_exc().split('\n'))))
        info = self.model._meta.app_label, self.model._meta.model_name
        return HttpResponseRedirect(reverse("admin:%s_%s_changelist" % info))

3 View Complete Implementation : registration.py
Copyright Apache License 2.0
Author : Integreat
def pastword_reset_done(request):
    """View linked to the Pastword reset functionality
    Args:
            request: Object representing the user call
    Returns:
            HttpResponseRedirect: Redirect after pastword reset
    """

    messages.info(request, (_('A message with instructions for resetting your pastword '
                              'has been sent to the e-mail address provided.')))
    return HttpResponseRedirect(reverse('pastword_reset'))

3 View Complete Implementation : views.py
Copyright The Unlicense
Author : nerosketch
    def form_valid(self, form):
        bot_type = form.cleaned_data.get('bot_type')
        if isinstance(bot_type, int) and bot_type > 0:
            if bot_type == 1:
                self.success_url = resolve_url('messenger:add_viber_messenger')
                return super().form_valid(form)
        messages.info(self.request, _('Unexpected bot type'))
        self.success_url = resolve_url('messenger:messengers_list')
        return super().form_valid(form)

3 View Complete Implementation : upload.py
Copyright Apache License 2.0
Author : byro
    def post(self, request, *args, **kwargs):
        obj = self.get_object()
        errors = success = 0
        for real_transaction in obj.transactions.all():
            try:
                real_transaction.derive_virtual_transactions()
                success += 1
            except Exception:
                errors += 1
        messages.info(
            request,
            "{success} successful matches, {errors} errors.".format(
                success=success, errors=errors
            ),
        )
        return redirect("office:finance.uploads.list")

3 View Complete Implementation : views.py
Copyright MIT License
Author : openfun
@api_view(["POST"])
# pylint: disable=unused-argument
def bootstrap_elasticsearch(request, version):
    """Regenerate the Elasticsearch index."""
    user = request.user
    if not (user.is_staff and request.user.has_perm("search.can_manage_elasticsearch")):
        return HttpResponse(
            force_text(_("You are not allowed to manage the search index.")),
            status=403 if request.user.is_authenticated else 401,
        )

    management.call_command("bootstrap_elasticsearch")

    messages.info(request, _("The search index was successfully bootstrapped"))
    return Response({})

3 View Complete Implementation : signals.py
Copyright MIT License
Author : line
@run_once(trigger_write_rules)
def _trigger_write_rules(signal, **kwargs):
    targets = [server.host for server in models.Prometheus.objects.all()]
    for target in targets:
        logger.info('Queueing write_rules on %s', target)
        tasks.write_rules.apply_async(queue=target)
    if 'request' in kwargs:
        messages.info(kwargs['request'], 'Updating rules on {}'.format(targets))
    return True

3 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : respawner
    def post(self, request):
        form = LoginForm(request, data=request.POST)

        if form.is_valid():
            # Check where should the user be redirected
            next_redirect = request.POST.get("next", "")
            if not is_safe_url(url=next_redirect, allowed_hosts=[request.get_host()]):
                next_redirect = reverse("home")

            auth_login(request, form.get_user())
            messages.info(request, "Logged in as {}.".format(request.user))
            return HttpResponseRedirect(next_redirect)

        return render(request, self.template, {"form": form})

3 View Complete Implementation : views.py
Copyright MIT License
Author : pyconsk
def index(request):
    try:
        timewise, event_type = LANDING_PAGE.split('_')
        timewise = timewise.lower()
        event_type = event_type.upper()
    except BaseException as be:
        raise ('%s\nIncorrect LANDING_PAGE setting, need latest|earliest_conference|meetup', be)

    events = Event.objects.published().filter(event_type=getattr(Event, event_type))
    selected_event = getattr(events, timewise)('date_from') if events else None
    if not selected_event:
        messages.info(request, _('No %s event has been found. Redirected to default list.' % event_type))
        return render(request=request, template_name='konfera/list_events.html')

    return redirect('event_details', slug=selected_event.slug)

3 View Complete Implementation : views.py
Copyright MIT License
Author : line
    def post(self, request, pk):
        farm = get_object_or_404(models.Farm, id=pk)
        # If any hosts are added or removed, then we want to
        # trigger a config refresh
        if any(farm.refresh()):
            signals.trigger_write_config.send(request)
        messages.info(request, 'Refreshed hosts')
        if 'next' in request.POST:
            return HttpResponseRedirect(request.POST['next'])
        # If we don't have an explicit redirect, we can redirect to the farm
        # itself
        return redirect(farm)

3 View Complete Implementation : task.py
Copyright MIT License
Author : telminov
    def post(self, *args, **kwargs):
        task = self.get_object()
        if task.status in consts.RUN_STATUSES:
            task.stop()
        else:
            messages.info(self.request, 'Task is not run')
        return redirect('task_search')

3 View Complete Implementation : views.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
@facebook_required(scope='publish_stream,user_photos')
def image_upload(request):
    fb = get_persistent_graph(request)
    pictures = request.REQUEST.getlist('pictures')

    for picture in pictures:
        fb.set('me/photos', url=picture, message='the writing is one The '
            'wall image %s' % picture)

    messages.info(request, 'The images have been added to your profile!')

    return next_redirect(request)

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : Uninett
def set_interface_values(account, interface, request):
    """Use snmp to set the values in the request on the netbox"""

    fac = get_factory(interface.netbox)

    if fac:
        # Order is important here, set_voice need to be before set_vlan
        set_voice_vlan(fac, interface, request)
        set_ifalias(account, fac, interface, request)
        set_vlan(account, fac, interface, request)
        set_admin_status(fac, interface, request)
        save_to_database([interface])
    else:
        messages.info(request, 'Could not connect to netbox')

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def unpublish_project(self):
        project = self.project
        if project.is_draft:
            messages.info(self.request, _('Project is already unpublished'))
            return

        project.is_draft = True
        project.save()
        signals.project_unpublished.send(sender=None,
                                         project=project,
                                         user=self.request.user)
        messages.success(self.request,
                         _('Project successfully unpublished.'))

3 View Complete Implementation : helper.py
Copyright MIT License
Author : vicalloy
def add_processed_message(request, process_instance, act_descn='Processed'):
    messages.info(
        request,
        'Process "%s" has been %s. Current status:"%s" Current user:"%s"' %
        (
            process_instance.no, act_descn, process_instance.cur_node.name,
            process_instance.get_operators_display()
        )
    )

3 View Complete Implementation : views.py
Copyright GNU General Public License v3.0
Author : cuducos
def screen_name_view(action):
    def view(request):
        if not request.user.is_authenticated:
            login_url = resolve_url("admin:login")
            msg = f"User not authenticated. Please, login at {login_url}"
            return JsonResponse({"error": msg}, status=403)

        if request.method != "POST":
            return HttpResponseNotAllowed(("POST",))

        form = ScreenNameForm(request.POST)
        if not form.is_valid():
            return JsonResponse(form.errors, status=400)

        message = action(form.cleaned_data["screen_name"])
        messages.info(request, message)
        return redirect(resolve_url(settings.MAIN_ADMIN_VIEW))

    return view

3 View Complete Implementation : processinstance.py
Copyright MIT License
Author : vicalloy
def delete(request):
    pks = request.POST.getlist('pk') or request.GET.getlist('pk')
    instances = ProcessInstance.objects.filter(pk__in=pks)
    for instance in instances:
        # only workflow admin can delete
        if instance.is_wf_admin(request.user):
            instance.delete()
    messages.info(request, 'Deleted')
    return redirect(reverse('wf_list_wf'))

3 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : liqd
    def unpublish_module(self):
        module = self.get_object()
        if module.is_draft:
            messages.info(self.request, _('Module is already removed'))
            return

        module.is_draft = True
        module.save()

        signals.module_unpublished.send(sender=None,
                                        module=module,
                                        user=self.request.user)

        messages.success(self.request,
                         _('Module successfully removed.'))

3 View Complete Implementation : views.py
Copyright MIT License
Author : GottfriedCP
def sync(request):
    """Restore transactions from honest node."""
    deleted_old_votes = Vote.objects.all().delete()[0]
    print('\nTrying to sync {} transactions with 1 node(s)...\n'.format(deleted_old_votes))
    bk_votes = VoteBackup.objects.all().order_by('timestamp')
    for bk_v in bk_votes:
        vote = Vote(id=bk_v.id, vote=bk_v.vote, timestamp=bk_v.timestamp, block_id=bk_v.block_id)
        vote.save()
    print('\nSync complete.\n')
    messages.info(request, 'All blocks have been synced successfully.')
    return redirect('simulation:blockchain')

3 View Complete Implementation : offers.py
Copyright MIT License
Author : CodeForPoznan
    @staticmethod
    def get(request, pk):  # pylint: disable=invalid-name
        """Method which allows to delete selected offer

        :param request: WSGIRequest instance
        :param pk: Offer id
        """
        offer = get_object_or_404(Offer, pk=pk)
        if (
                request.user.is_authenticated() and
                request.user.userprofile.is_administrator
        ):
            offer.publish()
            messages.info(request, "Oferta została zaakceptowana.")
            return redirect(settings.ANGULAR_ROOT)

        return HttpResponseForbidden()

3 View Complete Implementation : views.py
Copyright BSD 2-Clause "Simplified" License
Author : evrenesat
@facebook_required(scope='publish_stream')
def wall_post(request):
    fb = get_persistent_graph(request)

    message = request.REQUEST.get('message')
    fb.set('me/feed', message=message)

    messages.info(request, 'Posted the message to your wall')

    return next_redirect(request)

3 View Complete Implementation : signals.py
Copyright MIT License
Author : line
@run_once(trigger_write_urls)
def _trigger_write_urls(signal, **kwargs):
    targets = [server.host for server in models.Prometheus.objects.all()]
    for target in targets:
        logger.info('Queueing write_urls on %s', target)
        tasks.write_urls.apply_async(queue=target)
    if 'request' in kwargs:
        messages.info(kwargs['request'], 'Updating urls on {}'.format(targets))
    return True

3 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : respawner
    def get(self, request, slug):
        internet_exchange = get_object_or_404(InternetExchange, slug=slug)

        # Check if the PeeringDB ID is valid
        if not internet_exchange.is_peeringdb_valid():
            # If not, try to fix it automatically
            peeringdb_id = internet_exchange.get_peeringdb_id()
            if peeringdb_id != 0:
                internet_exchange.peeringdb_id = peeringdb_id
                internet_exchange.save()
                messages.info(
                    request,
                    "The PeeringDB record reference for this IX was invalid, it has been fixed.",
                )

        context = {"internet_exchange": internet_exchange}
        return render(request, "peering/ix/details.html", context)

0 View Complete Implementation : build.py
Copyright GNU Affero General Public License v3.0
Author : 82Flex
    def save_model(self, request, obj, form, change):
        """
        Set the active release, call building procedure, and then save.
        
        :type obj: Build
        """
        setting = preferences.Setting
        obj.active_release = setting.active_release
        super(BuildAdmin, self).save_model(request, obj, form, change)
        
        if setting.active_release is not None:
            build_args = {
                "build_uuid": obj.uuid,
                "build_all": setting.downgrade_support,
                "build_p_diff": setting.enable_pdiffs,
                "build_compression": setting.packages_compression,
                "build_secure": setting.gpg_signature,
                "build_validation": setting.packages_validation,
                "build_release": obj.active_release.id,
            }
            if settings.ENABLE_REDIS is True:
                queue = django_rq.get_queue('high')
                build_job = queue.enqueue(build_procedure, build_args)
                obj.job_id = build_job.id
                messages.info(request, mark_safe(
                    _("The Build \"<a href=\"%(job_detail)s\">%(obj)s</a>\" generating job has been added to the \"<a href=\"%(jobs)s\">high</a>\" queue.").format(
                        job_detail=reverse('rq_job_detail', kwargs={
                            'queue_index': 1,
                            'job_id': build_job.id,
                        }),
                        obj=str(obj),
                        jobs=reverse('rq_jobs', args=(1, )),
                    )
                ))
            else:
                build_procedure(build_args)
                messages.info(request, _("The Build \"%s\" generating job has been finished.") % str(obj))
            obj.save()

0 View Complete Implementation : section.py
Copyright GNU Affero General Public License v3.0
Author : 82Flex
    def generate_icon_package(self, request, queryset):
        """

        :type request: request
        """
        result_set = queryset.values()  # return ValuesQuerySet object
        list_result_set = [entry for entry in result_set]

        site = Site.objects.get(id=settings.SITE_ID)
        scheme = "http"
        if settings.SECURE_SSL is True:
            scheme = "https"
        site_url = "%s://%s" % (scheme, site.domain)

        domain_components = site.domain.split('.')
        domain_components.reverse()
        domain_components.append("source-icon")
        package_identifier = ".".join(domain_components)

        release_label = preferences.Setting.active_release.label
        package_name = _("%s Source Icon") % release_label

        latest_version = Package.objects.filter(c_package=package_identifier).last()
        latest_version_str = None
        if latest_version is not None:
            latest_version = latest_version.get_latest_version()
            if latest_version is not None:
                latest_version_str = latest_version.c_version

        version_str = "0.1"
        latest_num = 0
        if latest_version_str is not None:
            latest_arr = latest_version_str.split('-')
            if len(latest_arr) > 1:
                version_str = latest_arr[0]
                latest_num = int(latest_arr[1])
        new_version_str = '-'.join([version_str, str(latest_num + 1)])

        current_user = request.user
        user_name = current_user.username
        user_email = current_user.email

        conf = {
            "sections": list_result_set,
            "control": {
                "package": package_identifier,
                "name": package_name,
                "version": new_version_str,
                "author-name": user_name,
                "author-email": user_email,
                "maintainer-name": user_name,
                "maintainer-email": user_email,
                "sponsor-name": user_name,
                "sponsor-site": site_url,
                "description": _('Auto generated section icon package for %s.') % release_label,
                "architecture": "iphoneos-arm",
            }
        }
        if settings.ENABLE_REDIS is True:
            queue = django_rq.get_queue('default')
            queue.enqueue(build_section_package_procedure, conf)
            messages.info(request, mark_safe(
                _("Section icon package generating job has been added to the \"<a href=\"%s\">default</a>\" queue.") % (
                    reverse('rq_jobs', args=(0, ))
                )
            ))
        else:
            build_section_package_procedure(conf)
            messages.info(request, _("Section icon package generating job has been finished."))

        return redirect("admin:WEIPDCRM_version_changelist")

0 View Complete Implementation : version.py
Copyright GNU Affero General Public License v3.0
Author : 82Flex
    def save_model(self, request, obj, form, change):
        # field update
        """
        :param change: Boolean
        :param form: VersionForm
        :type obj: Version
        """
        # hash update
        obj.update_hash()
        super(VersionAdmin, self).save_model(request, obj, form, change)
        
        """
        Remove all excluded column (which are not in standard debian control part)
        to determine whether the related .deb file on file system should be updated.
        """
        excluded_column = ['enabled', 'created_at', 'os_compatibility', 'device_compatibility',
                           'update_logs', 'storage', 'online_icon', 'gallery', 'c_md5', 'c_sha1', 'c_sha256', 'c_sha512',
                           'c_size', 'download_times', 'rich_description']
        change_list = form.changed_data
        change_num = len(change_list)
        for change_var in change_list:
            if change_var in excluded_column:
                change_num -= 1
        if change is True and change_num > 0:
            update_job = obj.update_storage()
            if settings.ENABLE_REDIS is True and update_job is not None:
                messages.info(request, mark_safe(_("The Version \"<a href=\"%(job_detail)s\">%(obj)s</a>\" storage updating job has been added to the \"<a href=\"%(jobs)s\">high</a>\" queue.").format(
                        job_detail=reverse('rq_job_detail', kwargs={
                            'queue_index': 1,
                            'job_id': update_job.id,
                        }),
                        obj=str(obj),
                        jobs=reverse('rq_jobs', args=(1, ))
                    )
                ))
        else:
            past

0 View Complete Implementation : release.py
Copyright GNU Affero General Public License v3.0
Author : 82Flex
@staff_member_required
def set_default_view(request, release_id):
    """
    :param release_id: The release
    :param request: Django Request
    :return: Redirect Response
    """
    release_instance = Release.objects.get(id=release_id)
    
    messages.info(request, mark_safe(_(
        "Active release \"<a href=\"%(release_url)s\">%(release)s</a>\" has been set.").format(
            release_url=release_instance.get_admin_url(),
            release=str(release_instance)
        )
    ))
    
    setting_instance = Setting.objects.get()
    setting_instance.active_release = release_instance
    setting_instance.save()
    
    return redirect(setting_instance.get_admin_url())

0 View Complete Implementation : views.py
Copyright Apache License 2.0
Author : c3nav
def map_index(request, mode=None, slug=None, slug2=None, details=None, options=None, nearby=None,
              level=None, x=None, y=None, zoom=None, embed=None):

    # check for access token
    access_signed_data = request.GET.get('access')
    if access_signed_data:
        try:
            token = AccessPermissionForm.load_signed_data(access_signed_data)
        except SignedPermissionDataError as e:
            return HttpResponse(str(e).encode(), content_type='text/plain', status=400)

        num_restrictions = len(token.restrictions)
        with transaction.atomic():
            token.save()

            if not request.user.is_authenticated:
                messages.info(request, _('You need to log in to unlock areas.'))
                request.session['redeem_token_on_login'] = str(token.token)
                token.redeem()
                return redirect_to_login(request.path_info, 'site.login')

            token.redeem(request.user)
            token.save()

        messages.success(request, ungettext_lazy('Area successfully unlocked.',
                                                 'Areas successfully unlocked.', num_restrictions))
        return redirect('site.index')

    origin = None
    destination = None
    routing = False
    if slug2 is not None:
        routing = True
        origin = check_location(slug, request)
        destination = check_location(slug2, request)
    else:
        routing = (mode and mode != 'l')
        if mode == 'o':
            origin = check_location(slug, request)
        else:
            destination = check_location(slug, request)

    state = {
        'routing': routing,
        'origin': (origin.serialize(detailed=False, simple_geometry=True, geometry=False)
                   if origin else None),
        'destination': (destination.serialize(detailed=False, simple_geometry=True, geometry=False)
                        if destination else None),
        'sidebar': routing or destination is not None,
        'details': True if details else False,
        'options': True if options else False,
        'nearby': True if nearby else False,
    }

    levels = levels_by_short_label_for_request(request)

    level = levels.get(level, None) if level else None
    if level is not None:
        state.update({
            'level': level.pk,
            'center': (float(x), float(y)),
            'zoom': float(zoom),
        })

    initial_bounds = settings.INITIAL_BOUNDS
    if not initial_bounds:
        initial_bounds = tuple(chain(*Source.max_bounds()))

    ctx = {
        'bounds': json.dumps(Source.max_bounds(), separators=(',', ':')),
        'levels': json.dumps(tuple((level.pk, level.short_label) for level in levels.values()), separators=(',', ':')),
        'state': json.dumps(state, separators=(',', ':'), cls=DjangoJSONEncoder),
        'tile_cache_server': settings.TILE_CACHE_SERVER,
        'initial_level': settings.INITIAL_LEVEL,
        'primary_color': settings.PRIMARY_COLOR,
        'initial_bounds': json.dumps(initial_bounds, separators=(',', ':')) if initial_bounds else None,
        'last_site_update': json.dumps(SiteUpdate.last_update()),
        'ssids': json.dumps(settings.WIFI_SSIDS, separators=(',', ':')) if settings.WIFI_SSIDS else None,
        'random_location_groups': (
            ','.join(str(i) for i in settings.RANDOM_LOCATION_GROUPS) if settings.RANDOM_LOCATION_GROUPS else None
        ),
        'editor': can_access_editor(request),
        'embed': bool(embed),
    }

    if grid.enabled:
        ctx['grid'] = json.dumps({
            'rows': grid.rows,
            'cols': grid.cols,
            'invert_x': grid.invert_x,
            'invert_y': grid.invert_y,
        }, separators=(',', ':'), cls=DjangoJSONEncoder)

    csrf.get_token(request)

    if not embed:
        announcement = Announcement.get_current()
        if announcement:
            messages.info(request, announcement.text)

    response = render(request, 'site/map.html', ctx)
    set_tile_access_cookie(request, response)
    if embed:
        xframe_options_exempt(lambda: response)()
    return response

0 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : CCA-Public
@login_required(login_url="/login/")
def new_dip(request):
    if not request.user.is_editor():
        return redirect("home")

    DIPForm = modelform_factory(DIP, fields=("collection", "objectszip"))
    dip_form = DIPForm(request.POST or None, request.FILES or None)
    DublinCoreForm = modelform_factory(DublinCore, fields=("identifier",))
    dc_form = DublinCoreForm(request.POST or None)

    if request.method == "POST" and dip_form.is_valid() and dc_form.is_valid():
        dip = dip_form.save(commit=False)
        dip.dc = dc_form.save()
        dip.import_status = DIP.IMPORT_PENDING
        dip.save()

        # Extract and parse METS file asynchronously
        chain(extract_mets.s(dip.objectszip.path), parse_mets.s(dip.pk)).on_error(
            save_import_error.s(dip_id=dip.pk)
        ).delay()

        # Show notification to user about import in progress
        messages.info(
            request,
            _(
                "A background process has been launched to extract and parse "
                "the METS file. After the process finishes and the interface "
                "is reloaded, a link to the Folder will show up in the "
                "Folders table below."
            ),
        )

        if dip.collection:
            return redirect("collection", pk=dip.collection.pk)
        else:
            return redirect("orphan_dips")

    return render(request, "new_dip.html", {"dip_form": dip_form, "dc_form": dc_form})

0 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : CCA-Public
@login_required(login_url="/login/")
def edit_collection(request, pk):
    if not request.user.is_editor():
        return redirect("collection", pk=pk)

    collection = get_object_or_404(Collection, pk=pk)
    CollectionForm = modelform_factory(Collection, fields=("link",))
    collection_form = CollectionForm(request.POST or None, instance=collection)
    DublinCoreForm = modelform_factory(DublinCore, fields=DublinCore.enabled_fields())
    dc_form = DublinCoreForm(request.POST or None, instance=collection.dc)

    if request.method == "POST" and collection_form.is_valid() and dc_form.is_valid():
        dc_form.save()
        collection_form.save()
        if collection.requires_es_descendants_update():
            messages.info(
                request,
                _(
                    "A background process has been launched to update the "
                    "Collection metadata in the Elasticsearch index for the "
                    "related Digital Files."
                ),
            )
        return redirect("collection", pk=pk)

    return render(
        request,
        "edit_collection.html",
        {
            "collection_form": collection_form,
            "dc_form": dc_form,
            "collection": collection,
        },
    )

0 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : CCA-Public
@login_required(login_url="/login/")
def edit_dip(request, pk):
    if not request.user.is_editor():
        return redirect("dip", pk=pk)

    dip = get_object_or_404(DIP, pk=pk)
    DIPForm = modelform_factory(DIP, fields=("collection",))
    dip_form = DIPForm(request.POST or None, instance=dip)
    DublinCoreForm = modelform_factory(DublinCore, fields=DublinCore.enabled_fields())
    dc_form = DublinCoreForm(request.POST or None, instance=dip.dc)

    if request.method == "POST" and dip_form.is_valid() and dc_form.is_valid():
        dc_form.save()
        dip_form.save()
        if dip.requires_es_descendants_update():
            messages.info(
                request,
                _(
                    "A background process has been launched to update the "
                    "ancestors metadata in the Elasticsearch index for the "
                    "related Digital Files."
                ),
            )
        return redirect("dip", pk=pk)

    return render(
        request, "edit_dip.html", {"dip_form": dip_form, "dc_form": dc_form, "dip": dip}
    )

0 View Complete Implementation : views.py
Copyright GNU Affero General Public License v3.0
Author : CCA-Public
@login_required(login_url="/login/")
def delete_collection(request, pk):
    if not request.user.is_superuser:
        return redirect("collection", pk=pk)

    collection = get_object_or_404(Collection, pk=pk)
    dc = get_object_or_404(DublinCore, pk=collection.dc_id)
    form = DeleteByDublinCoreForm(
        request.POST or None, instance=dc, initial={"identifier": ""}
    )
    if form.is_valid():
        if collection.requires_es_descendants_delete():
            messages.info(
                request,
                _(
                    "A background process has been launched to delete the "
                    "descendant Folders and Digital Files from the Elasticsearch "
                    "indexes."
                ),
            )
        collection.delete()
        return redirect("collections")

    return render(
        request, "delete_collection.html", {"form": form, "collection": collection}
    )