コード例 #1
0
    def extract_metadata(self, file):
        """ Extract all the metadata from the image and store """
        # Extract GPS data and store in Location
        gps_data = get_gps_data(self.exif_tags)

        if len(gps_data):
            Location.create({"position": gps_data}, self.entry)

        # Insert exif data into database
        exif_all = clean_exif(self.exif_tags)

        if len(exif_all):
            self.entry.media_data_init(exif_all=exif_all)

        # Extract file metadata
        try:
            im = Image.open(self.process_filename)
        except IOError:
            raise BadMediaFail()

        metadata = {
            "width": im.size[0],
            "height": im.size[1],
        }

        self.entry.set_file_metadata(file, **metadata)
コード例 #2
0
ファイル: processing.py プロジェクト: piratas/biblioteca
    def extract_metadata(self, file):
        """ Extract all the metadata from the image and store """
        # Extract GPS data and store in Location
        gps_data = get_gps_data(self.exif_tags)

        if len(gps_data):
            Location.create({"position": gps_data}, self.entry)

        # Insert exif data into database
        exif_all = clean_exif(self.exif_tags)

        if len(exif_all):
            self.entry.media_data_init(exif_all=exif_all)

        # Extract file metadata
        try:
            im = Image.open(self.process_filename)
        except IOError:
            raise BadMediaFail()

        metadata = {
            "width": im.size[0],
            "height": im.size[1],
        }

        self.entry.set_file_metadata(file, **metadata)
コード例 #3
0
    def extract_metadata(self):
        # Is there any GPS data
        gps_data = get_gps_data(self.exif_tags)

        # Insert exif data into database
        exif_all = clean_exif(self.exif_tags)

        if len(exif_all):
            self.entry.media_data_init(exif_all=exif_all)

        if len(gps_data):
            Location.create({"position": gps_data}, self.entry)
            self.entry.media_data_init(**gps_data)
コード例 #4
0
ファイル: views.py プロジェクト: mtlynch/mediagoblin
def edit_profile(request, url_user=None):
    # admins may edit any user profile
    if request.user.username != url_user.username:
        if not request.user.has_privilege(u'admin'):
            raise Forbidden(_("You can only edit your own profile."))

        # No need to warn again if admin just submitted an edited profile
        if request.method != 'POST':
            messages.add_message(
                request, messages.WARNING,
                _("You are editing a user's profile. Proceed with caution."))

    user = url_user

    # Get the location name
    if user.location is None:
        location = ""
    else:
        location = user.get_location.name

    form = forms.EditProfileForm(request.method == 'POST' and request.form
                                 or None,
                                 url=user.url,
                                 bio=user.bio,
                                 location=location)

    if request.method == 'POST' and form.validate():
        user.url = six.text_type(form.url.data)
        user.bio = six.text_type(form.bio.data)

        # Save location
        if form.location.data and user.location is None:
            user.get_location = Location(
                name=six.text_type(form.location.data))
        elif form.location.data:
            location = user.get_location
            location.name = six.text_type(form.location.data)
            location.save()
        else:
            user.location = None

        user.save()

        messages.add_message(request, messages.SUCCESS,
                             _("Profile changes saved"))
        return redirect(request,
                        'mediagoblin.user_pages.user_home',
                        user=user.username)

    return render_to_response(request, 'mediagoblin/edit/edit_profile.html', {
        'user': user,
        'form': form
    })