How can I change the order for the ActiveAdmin Comments model?
With my own models I use
menu priority: NUMBER
in the Admin class. But what about its own Comments class?
I had a similar problem with ActiveAdmin 1.0beta and wanted to post my solution for posterity.
In initializers/active_admin.rb if you add the "Comments" as a label and disable them in the menu you can move the comments to a dropdown or to the end of the main menu list.
config.show_comments_in_menu = false
# if active_admin >= 1.0, use `config.comments_menu = false`
#....
config.namespace :admin do |admin|
admin.build_menu do |menu|
menu.add label: 'Dashboard', priority: 0
menu.add label: 'Revenue', priority: 3
menu.add label: 'Costs', priority: 4
menu.add label: 'Categories', priority: 5
menu.add label: 'Users & Comments', priority: 6
menu.add label: 'Comments', parent: 'Users & Comments', url: "/admin/comments"
end
end
Nowadays, you can set the Comments menu priority in config/active_admin.rb like so:
config.comments_menu = { priority: 1 }
The workaround I've found was using negative numbers for menus that I want to be sure are shown before the Comments model.
Answer similar to accepted response, however, for those that want to maintain other AA menu defaults.
config.show_comments_in_menu = false
config.namespace :admin do |admin|
admin.build_menu :default do |menu|
menu.add label: 'Comments', parent: 'Misc', url: "/admin/comments"
end
end
Related
i have it so when entering the info into the signup input boxes and hitting the submit button.. it saves into the realtimedb in firebase auth.. the problem comes when i want to authenticate a user and then if the user isn't in the db i need to display a message
basically my code is...
loginsignup.py
from kivy.core.text import LabelBase
from kivy.core.window import Window
from kivy.lang import Builder
from kivy.uix.screenmanager import Screen,ScreenManager
from kivymd.app import MDApp
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
class MyFirebaseSignup:
def sign_up(self, username, email, password, login_message=None):
try:
user = auth.create_user_with_email_and_password(email, password)
data = {"email": email, "password": password, "idToken": True}
info = auth.get_account_info(user["idToken"])
auth.send_email_verification(user["idToken"])
password = data.get("password")
print("Successfully created account")
#Go to login.kv page
except:
print("Invalid")
#Display Error message from firebase id: signup_message (signup.kv)
pass
class MyFirebaseLogin():
def Login(self, email, password):
try:
login = auth.sign_in_with_email_and_password(email, password)
info = auth.get_account_info(login["idToken"])
print("The data of text field is : ",self.root.ids.data.login)
print("Successfully Logged in")
#Go to profile.kv page
except:
print("Invalid")
#Display Error message from firebase id: login_message (login.kv)
pass
.....
def build(self):
screen_manager = ScreenManager()
screen_manager.add_widget(Builder.load_file("main.kv"))
screen_manager.add_widget(Builder.load_file("signup.kv"))
screen_manager.add_widget(Builder.load_file("login.kv"))
screen_manager.add_widget(Builder.load_file("forgotpassword.kv"))
screen_manager.add_widget(Builder.load_file("profile.kv"))
self.my_firebasesignup = MyFirebaseSignup()
self.my_firebaselogin = MyFirebaseLogin()
#self.firebaseForgotPassword = MyFirebaseForgotPassword()
return screen_manager
if __name__ == "__main__":
LoginSignup().run()
signup.kv
<SignupScreen>:
MDScreen:
name: "signup"
id: signup
MDFloatLayout:
text: "Create a new account"
MDLabel:
id: signup_message
color: (1,0,0,1)
MDFloatLayout:
TextInput:
id: login_username
hint_text: "Username"
multiline: False
MDFloatLayout:
TextInput:
id: login_email
hint_text: "Email"
multiline: False
MDFloatLayout:
TextInput:
id: login_password
hint_text: "Password"
multiline: False
password: True
Button:
text: "SIGNUP"
on_release:
print("Sign up", login_email.text, login_password.text)
app.my_firebasesignup.sign_up(login_username.text,login_email.text,login_password.text)
MDLabel:
text: "Already have an account?"
MDTextButton:
text: "Sign in"
on_release:
root.manager.transition.direction = "left"
root.manager.current = "login"
login.kv
<LoginScreen>:
MDScreen:
name: "login"
id: login
MDFloatLayout:
MDLabel:
text: "Sign in to continue"
MDLabel:
id: login_message
color: (1,0,0,1)
TextInput:
id: login_email
hint_text: "Email"
multiline: False
MDFloatLayout:
TextInput:
id: login_password
hint_text: "Password"
multiline: False
password: True
Button:
text: "LOGIN"
on_release:
print("Sign in", login_email.text, login_password.text)
app.my_firebaselogin.Login(login_email.text,login_password.text)
MDTextButton:
text: "Forgot Password?"
on_release:
root.manager.transition.direction = "left"
#root.manager.current = "forgotpassword"
MDLabel:
text: "Don't have an account?"
MDTextButton:
text: "Sign up"
on_release:
root.manager.transition.direction = "left"
root.manager.current = "signup"
i cant find in any of the tutorials online how to display the errors using a label or if successful to move forward to a new page
Basically how do i:
Once signed up successfully, then go to login.kv page ... if my other buttons on other screens to go on release, root.manager.current = "login"
If there is an error in the Signup details, display those details in the signup_message on the signup.kv page?
I took out the formatting, etc... and im sure it is so simple.. but i cant figure it out
once i know how to do it once... il be able to do it on the others, etc
In my project i have a gem that uses paperclip for file attachments. an example model in the gem:
class Example do
...
has_attached_file :image,
styles: { mini: '32x32>', normal: '128x128>' },
default_style: :mini,
url: '/example/url/:id/:style/:basename.:extension',
path: ':rails_root/public/example/url/:id/:style/:basename.:extension',
...
end
I want to modify the image so instead of having mini and normal sizes, i can add another size. I also want to change the path. How do i go about this? i tried creating a decorator like:
Example.class_eval do
has_attached_file :image,
styles: { mini: '32x32>', normal: '128x128>', large: '1024x1024' },
default_style: :mini,
url: '/example/url/:id/:style/:basename.:extension',
path: 'updated/example/url/:id/:style/:basename.:extension',
end
this didn't do anything.
Not sure if you've solved this by now, but for any future viewers of this question...
You can do this by modifying the attachment_definitions property of the class. For instance you could add an initializer with:
Example.attachment_definitions[:image][:styles][:normal] = "1000x500"
Example.attachment_definitions[:image][:path] = '...'
Does anyone have experience with the Redcarpet and Rouge gems for Rails?
I'm trying to use the gems for syntaxhighlighting in my blogapplication. I based my implementation on this blogpost:
http://www.brettdemetris.com/posts/4
These are the steps I took:
I implemented the gems (Redcarpet, Rouge)
my Applicationhelper file looks like this:
app/helpers/application_helper.rb
module ApplicationHelper
require 'rouge'
require 'rouge/plugins/redcarpet'
class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet
def block_code(code, language)
Rouge.highlight(code, language || 'text', 'html')
end
end
def markdown(text)
options = {
filter_html: true,
hard_wrap: true,
link_attributes: { rel: 'nofollow', target: "_blank" },
space_after_headers: true,
fenced_code_blocks: true
}
extensions = {
autolink: true,
highlight: true,
superscript: true,
disable_indented_code_blocks: true
}
renderer = Redcarpet::Render::HTML.new(options)
markdown = Redcarpet::Markdown.new(renderer, extensions)
markdown.render(text).html_safe
end
end
I have a stylesheet for Rouge:
app/assets/stylesheets/rouge.css.erb
<%= Rouge::Themes::Github.render(:scope => '.highlight, code') %>
.highlight {
background-color: #f5f7f9;
padding: 1em;
}
.highlight .err {
color: #a61717;
background-color: #f5f7f9;
}
Apperently the conversion to markdown works, but not the syntaxhighlighting with Rouge:
for example when I use this code in my blogpost:
```ruby
e = "some ruby code"
e.puts
```
the code is not highlighted.
the output of the above code snippet is this:
<pre><code class="ruby">e = "some variable"
e.puts
</code></pre>
Am I missing something?
my code repository is here:
https://github.com/acandael/personalsite/tree/markdown
any advice is highly appreciated
greetings,
Anthony
For people interested, this is the working code in my applicationhelper:
app/helpers/application_helper.rb
module ApplicationHelper
require 'redcarpet'
require 'rouge'
require 'rouge/plugins/redcarpet'
class HTML < Redcarpet::Render::HTML
include Rouge::Plugins::Redcarpet
def block_code(code, language)
Rouge.highlight(code, language || 'text', 'html')
end
end
def markdown(text)
options = {
filter_html: true,
hard_wrap: true,
link_attributes: { rel: 'nofollow', target: "_blank" }
}
extensions = {
autolink: true,
highlight: true,
superscript: true,
disable_indented_code_blocks: true,
space_after_headers: true,
fenced_code_blocks: true
}
#renderer = Redcarpet::Render::HTML.new(options)
renderer = HTML.new(options)
markdown = Redcarpet::Markdown.new(renderer, extensions)
markdown.render(text).html_safe
end
end
this is how I implemented it in the view:
app/views/articles/show.html.erb
<%= raw(markdown(#article.body)) %>
The markdown and syntaxhighlighting is working now.
Is there a way to create multi select dropdown in Rally for user story's Schedule state fields. I want to filter user stories based on their schedule state.
I have gone through the doc and Rallyfieldpicker seems perfect for this but it is unclear to me how to filter user story fields.
I've tried the following to no effect:
{
xtype: 'rallyfieldpicker',
autoExpand: true,
modelType: 'userstory',
fieldLabel: 'Filter by Schedule State',
filterFieldName: 'ScheduleState'
}
Could someone help me with this. Thanks!
rallyfieldvaluecombobox has a multiSelect config property. There are no checkboxes in front of each selection to indicate that multiselection is allowed, but it supports multi-selection nevertheless.
this.add({
xtype: 'rallyfieldvaluecombobox',
model: 'UserStory',
multiSelect: true,
field: ScheduleState,
listeners: {
select: this._getFilter,
ready: this._getFilter,
scope: this
}
});
See an example of a custom app that uses it in this github repo
I am trying to create a hidden form with some data, which needs to be submitted to a jsp page (which gets open in a new window), but all this would happen programatically, without user pressing submit button.
My Sample code
var fsquery = "abcd";
var emailId = "as#gmail.com";
var portalPsswd = "password";
var projectId = "123";
var kbUrl = "some url which will consume form post parameters";
var pv="1.2",pn="ADA";
this.kbform=isc.DynamicForm.create({
width: 300,
fields: [
{type: "hiddenitem", name: "EMAIL_ID", defaultValue:emailId },
{type: "hiddenitem", name: "PORTAL_PASSWORD", defaultValue:portalPsswd},
{type: "hiddenitem", name: "PROJECT_ID", defaultValue:projectId},
{type: "hiddenitem", name: "FSQUERY", defaultValue:fsquery},
{type: "hiddenitem", name: "PRODUCT_VERSION", defaultValue:pv},
{type: "hiddenitem", name: "PRODUCT_NAME", defaultValue:pn},
{type: "hiddenitem", name: "ORIGIN", defaultValue:"Administrator"},
{type: "submit", name: "submit", defaultValue: "submit"}
],
action: kbUrl,
target: "_blank",
method: "POST",
canSubmit: true
});
this.kbform.submit();
the last statement does not submit the form automatically, but if I click the submit button provided, it works perfectly as needed.
Please provide me a solution which will help me simulate "submit" type button functionality to submit the form.
You can try this sample code here under "text.js" tab
I'm not sure about this, but have you tried triggering the submit on a window.onload event? I don't think the form is available until the document is fully loaded. I'm sorry I don't have any examples.