Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Remove microblog item #11

Open
maartenkling opened this issue Nov 17, 2013 · 8 comments
Open

Feature: Remove microblog item #11

maartenkling opened this issue Nov 17, 2013 · 8 comments

Comments

@maartenkling
Copy link
Contributor

As a manager/siteadministrator i need to be able to delete one (1) microblog item from another user, as it can contain text that does not match the site terms and conditions

@hvelarde
Copy link
Contributor

👍

1 similar comment
@macagua
Copy link
Contributor

macagua commented Mar 14, 2014

👍

@maartenkling
Copy link
Contributor Author

for now in browser view :)

<form method="post">
user: <input type="text" name="user" tal:attributes="value python: request.form.get('user', '')">
    <input type="submit" name="submit" class="btn">
</form>

<hr />
<tal:block tal:repeat="activity view/findkey">
    <span tal:content="python: activity[0]" /><br />
    <span tal:content="python: activity[1].text" />
    <form method="post">
        <input type="text" name="key" tal:attributes="value python: activity[0]">
        <input type="text" name="user" tal:attributes="value python: request.form.get('user', '')">
        <input type="submit" name="delete" value="delete" class="btn">
    </form>
     <br /><br />

</tal:block>

from plonesocial.activitystream.integration import PLONESOCIAL
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from Products.Five import BrowserView

class activityPopperView(BrowserView):

template = ViewPageTemplateFile('templates/activitypopper.pt')

def __call__(self):

    if self.request.get('REQUEST_METHOD', 'GET').upper() == 'POST':
        key = self.request.form.get('key', False)
        user = self.request.form.get('user', False)
        if key and user:
            self.pop(key, user)

    return self.index()

def findkey(self):
    container = PLONESOCIAL.microblog
    user = self.request.form.get('user', False)
    if user:
        return container.user_items(user)
    return False

def pop(self, key, user):
    container = PLONESOCIAL.microblog

    # remove from user mapping
    container._user_mapping[user].remove(long(key))

    # remove from tag mapping
    taglist = [x[1] for x in container._tag_mapping.items()]
    for x in taglist:
        if long(key) in x.keys():
            x.remove(long(key))

    # remove from uuid mapping
    uuidlist = [x[1] for x in container._uuid_mapping.items()]
    for x in uuidlist:
        if long(key) in x.keys():
            x.remove(long(key))

    # pop status
    container._status_mapping.pop(long(key))
    return

@hvelarde
Copy link
Contributor

is always better in a pull request with tests ;-)

@hvelarde
Copy link
Contributor

@maartenkling what happened with this?

@maartenkling
Copy link
Contributor Author

@hvelarde nothing by me, i implemented a browser view in a separated package, but the code is okay

@hvelarde
Copy link
Contributor

@gyst do you want to include this on the package?

@gyst
Copy link
Member

gyst commented May 31, 2014

@hvelarde yes, but "is always better in a pull request with tests ;-)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants